C运行时库中关于时间处理的函数

说明

下文主要列了下时间函数,具体用时,还是要查看文档的详细说明

时间函数

asctime, _wasctime, asctime_s, _wasctime_s

将结构体struct tm的时间转换成字符串的时间,带_s的函数更安全,推荐使用。struct tm通常由 gmtimelocaltime获取。函数根据当前系统本地时间区域设置进行格式化输出字符串的时间。

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 _timebstruct __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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值