time_t now = time(nullptr);
//now is seconds since 1970-01-01 00:00:00 UTC
struct tm utcDate;
gmtime_r(&now, &utcDate);
//utcDate holds the current date in time zone UTC
struct tm localDate;
localtime_r(&now, &localDate);
//localDate holds the current date in the local time zone
// Standard C knows only UTC and the local zone;
// another zone is set through the POSIX variable TZ.
setenv("TZ", "JST-9", 1);
tzset();
struct tm tokyoDate;
localtime_r(&now, &tokyoDate);
//tokyoDate holds the current date in time zone UTC +9:00
char sUtc[32], sLocal[32], sTokyo[32];
strftime(sUtc, sizeof sUtc, "%Y-%m-%d %H:%M:%S", &utcDate);
strftime(sLocal, sizeof sLocal, "%Y-%m-%d %H:%M:%S", &localDate);
strftime(sTokyo, sizeof sTokyo, "%Y-%m-%d %H:%M:%S", &tokyoDate);
printf("now is %lld\n", (long long)now);
printf("utcDate is %s\n", sUtc);
printf("localDate is %s\n", sLocal);
printf("tokyoDate is %s\n", sTokyo);