#include <stdio.h>
#include <time.h>
#include<Windows.h>
int main()
{
while(1)
{
time_t start_time, cur_time;
time_t now, t1;
t1 = time(&now);
printf("当前日历时间%u(距离1970年1月1日0时的秒数)\n", t1);
struct tm *localtp;
localtp = localtime(&now);
printf("现在的日期和时间是:%d年%d月%d日%d:%d:%d\n", localtp->tm_year + 1990,
localtp->tm_mon + 1, localtp->tm_mday, localtp->tm_hour, localtp->tm_min,localtp->tm_min);
printf("asctime呈现的本地时间:%s\n", asctime(localtp));
printf("ctime呈现的本地时间:%s\n", ctime(&now));
struct tm *gmtp;
gmtp = gmtime(&now);
printf("UTC时间:%s\n", asctime(gmtp));
time(&start_time);
do{
time(&cur_time);
}while(cur_time - start_time < 1);
}
}
|