Programming Tips - C/C++: Set the timezone for the current process

Date: 2023mar29 OS: Windows Language: C/C++ Q. C/C++: Set the timezone for the current process A.
// Warning: Sets the timezone for all threads! void TzSet(LPCSTR szTz) { char buf[1024]; _snprintf(buf, sizeof(buf), "TZ=%s", szTz); _putenv(buf); _tzset(); }
void ExampleUse() { TzSet("EST5EDT"); }