我想同时打印本地时间和UTC时间。问题在于两者都打印相同的UTC时间。
#include <time.h>
#include <stdio.h>
int main(void)
{
struct tm *local;
time_t t;
t = time(NULL);
local = localtime(&t);
printf("Local time and date: %s\n", asctime(local));
local = gmtime(&t);
printf("UTC time and date: %s\n", asctime(local));
return 0;
}