I have the timezone offset in seconds from a weather api. Would like to set the local time using this offset. #include <stdio.h> #include <time.h>
int main(void) {
char buf[80];
time_t disp_time;
struct tm *timeinfo;
time (&disp_time);
timeinfo = localtime (&disp_time);
strftime(buf, sizeof(buf), "%a %Y-%m-%d %H:%M:%S %Z", timeinfo);
printf("%s\n", buf);
return 0;
} This is a test from my program. Time is UTC. Need to subtract tz offset to get local time.
Scoured the internet looking for and explanation or an example. Nothing found.