C语言基础:mktime用法演示,输出时间差
#include <stdio.h>
#include <time.h>
int main(void)
{
time_t seconds;
struct tm time_fields;
time_fields.tm_mday = 4;
time_fields.tm_mon = 7;
time_fields.tm_year = 94;
time_fields.tm_hour = 0;
time_fields.tm_min = 0;
time_fields.tm_sec = 0;
seconds = mktime(&time_fields);
printf("The number of seconds between 7-4-94 and 1-1-70 is %ld\n",
seconds);
return 1;
}
输出结果:GCC编译
The number of seconds between 7-4-94 and 1-1-70 is 775929600
