头文件:<time.h>
需要数据类型:time_t,struct tm
需要函数:time_t mktime(struct tm * timeptr);
目标:将指定日期转换成距离1970.1.1所经过的秒数
过程:填写tm数据结构,传入函数中,返回一个time_t的结果。
下面是msdn关于mktime函数的描述:
time_t mktime( struct tm *timeptr ); __time32_t _mktime32( struct tm *timeptr ); __time64_t _mktime64( struct tm *timeptr ); |
_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.