#include <stdlib.h>
#include <time.h>
main() {
int ans;
time_t ct1;
struct tm *t;
time(&ct1);
ans = setenv("TZ","JST-9",1);
if (ans == 0) {
t=localtime(&ct1);
printf("%4d/%02d/%02d,%02d:%02d\n",
1900+t->tm_year,
1+t->tm_mon,
t->tm_mday,
t->tm_hour,
t->tm_min
);
} else {
t=gmtime(&ct1);
printf("%4d/%02d/%02d,%02d:%02d (gmt)\n",
1900+t->tm_year,
1+t->tm_mon,
t->tm_mday,
t->tm_hour,
t->tm_min
);
}
}
|