Search found 3 matches
- Thu Mar 12, 2026 12:50 pm
- Forum: ESP-IDF
- Topic: setenv and tzset not working
- Replies: 5
- Views: 256
Re: setenv and tzset not working
Does the forum allow deleting a post and going somewhere to hang one's head in shame? I honestly thought it was supposed to be day of month.
- Wed Mar 11, 2026 3:49 pm
- Forum: ESP-IDF
- Topic: setenv and tzset not working
- Replies: 5
- Views: 256
Re: setenv and tzset not working
OK, it works. I rarely use local time in my systems and LibC internally uses the same variable for storing time structs, so my multiple calls to gmtime , localtime was overwriting. So, it even works for the more complicated POSIX formats.
Thanks for responding.
Thanks for responding.
- Mon Mar 09, 2026 12:35 pm
- Forum: ESP-IDF
- Topic: setenv and tzset not working
- Replies: 5
- Views: 256
setenv and tzset not working
I'm using SNTP to set the system time and it's working fine. But then I try to set the local time;
time(&now);
setenv("TZ", "CST6CDT,M3.8.0/2,M11.1.0/2", 1);
tzset();
localtime_r(&now, &timeinfo);
strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
cli_print_msg("Local Time is: %s ...
time(&now);
setenv("TZ", "CST6CDT,M3.8.0/2,M11.1.0/2", 1);
tzset();
localtime_r(&now, &timeinfo);
strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
cli_print_msg("Local Time is: %s ...