说明
下文主要列了下时间函数,具体用时,还是要查看文档的详细说明
时间函数
asctime, _wasctime, asctime_s, _wasctime_s
将结构体struct tm 的时间转换成字符串的时间,带_s的函数更安全,推荐使用。struct tm 通常由 gmtime 或localtime 获取。函数根据当前系统本地时间区域设置进行格式化输出字符串的时间。
clock
返回当前进程已运行的cpu时钟滴答数。
ctime, _ctime32, _ctime64, _wctime, _wctime32, _wctime64, _ctime_s, _ctime32_s, _ctime64_s, _wctime_s, _wctime32_s, _wctime64_s
将time_t , __time32_t , __time64_t 的时间转换成字符串的时间,带_s的函数更安全,推荐使用。前述时间依次由函数time , _time32 , _time64 返回。函数根据当前系统本地时间区域设置进行格式化输出字符串的时间。
difftime, _difftime32, _difftime64
返回两个时间(time_t 或 __time32_t 或__time64_t )之差,单位是秒,
_ftime, _ftime32, _ftime64, _ftime_s, _ftime32_s, _ftime64_s
将当前系统时间通过类型struct _timeb 或struct __timeb64 返回,存储的时间是coordinated universal time (UTC)。带_s的函数更安全,推荐使用。
_futime, _futime32, _futime64
设置文件的修改时间
gmtime, _gmtime32, _gmtime64, gmtime_s, _gmtime32_s, _gmtime64_s
将类型time_t 或__time64_t 的时间转换成类型struct tm 的时间,带_s的函数更安全,推荐使用。
localtime, _localtime32, _localtime64, localtime_s, _localtime32_s, _localtime64_s
将类型time_t 或__time64_t 的时间按本地区域时间设置转换成类型struct tm 的时间,带_s的函数更安全,推荐使用。
_mkgmtime, _mkgmtime32, _mkgmtime64
将类型为struct tm 的UTC时间转换成类型为time_t 或__time64_t 的UTC时间。
mktime, _mktime32, _mktime64
Convert time to calendar value.
_mktime32 returns the specified calendar time encoded as a value of type time_t . If timeptr references a date before midnight, January 1, 1970, or if the calendar time cannot be represented, _mktime32 returns –1 cast to type time_t. When using _mktime32 and if timeptr references a date after 03:14:07 January 19, 2038, Coordinated Universal Time (UTC), it will return –1 cast to type time_t.
_mktime64 will return –1 cast to type __time64_t if timeptr references a date after 23:59:59, December 31, 3000, UTC.
_strdate, _wstrdate, _strdate_s, _wstrdate_s
Return current system date as string. The versions of these functions with the _s suffix are more secure.
More secure versions of these functions are available; see _strdate_s, _wstrdate_s. It is recommended that the more secure functions be used wherever possible.
The _strdate function copies the current system date to the buffer pointed to by datestr, formatted mm/dd/yy, where mm is two digits representing the month, dd is two digits representing the day, and yy is the last two digits of the year. For example, the string 12/05/99 represents December 5, 1999. The buffer must be at least 9 bytes long.
If datestr is a NULL pointer, the invalid parameter handler is invoked, as described in Parameter Validation. If execution is allowed to continue, these functions return -1 and set errno to EINVAL.
_wstrdate is a wide-character version of _strdate; the argument and return value of _wstrdate are wide-character strings. These functions behave identically otherwise.
strftime, wcsftime, _strftime_l, _wcsftime_l
Format date-and-time string for international use.
_strtime, _wstrtime, _strtime_s, _wstrtime_s
Return current system time as string. The versions of these functions with the _s suffix are more secure.
time, _time32, _time64
返回类型为time_t 或 __time32_t 或__time64_t 的当前系统时间(自1970-01-01 00:00:00经过的秒数),UTC格式
_tzset
Set external time variables from environment time variable TZ. Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.
_utime, _utime32, _utime64, _wutime, _wutime32, _wutime64
Set modification time for specified file using either current time or time value stored in structure. Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.
|