Why changing timezone from shell does not affect gettimeofday() even after reboot?
问题 I have changed on Ubuntu timezone using dpkg-reconfigure tzdata from UTC+2 to UTC+0 but running C code gettimeofday() still showing tz_minuteswest and tv_sec in previous timezone even after reboot. Only after running C code below once gettimeofday() starts to showing UTC+0 time: #include <stdlib.h> #include <stdio.h> #include <sys/time.h> int main() { struct timeval tv; struct timezone tz; setenv("TZ", "UTC", 1); tzset(); gettimeofday(&tv, &tz); tv.tv_sec -= 7200; tz.tz_minuteswest = 0;