#include <time.h>
#include <stdio.h>
int main()
{
time_t timeLocal;
time_t timeUTC;
struct tm tmLocal;
struct tm tmUTC;
char strTime[32] = {};
time(&timeLocal); // utc time
localtime_r(&timeLocal, &tmLocal);
timeUTC = mktime(&tmLocal); // utc time
localtime_r(&timeUTC, &tmUTC); // local time
strftime(strTime, 32, "%Y-%m-%d_%H:%M:%S", &tmUTC);
printf("strTime: %s\n", strTime);
gmtime_r(&timeUTC, &tmUTC); // utc time
strftime(strTime, 32, "%Y-%m-%d_%H:%M:%S", &tmUTC);
printf("strTime: %s\n", strTime);
printf("timeLocal = %d; timeUTC = %d local-utc = %d\n",
timeLocal, timeUTC, (timeLocal-timeUTC)/3600);
printf(ctime(&timeUTC));
return 0;
}