No TZ.h File for ESP32?
Posted: Wed Apr 26, 2023 8:29 pm
So, the ESP8266 Arduino core has a very handy file called 'TZ.h" located in:
…/esp8266\hardware\esp8266\3.1.1\cores\esp8266
It contains the Unix time zone codes ('TZ' environment variable) for hundreds of locations around the world. They're defined with human-readable macros. For example:
However, this file doesn't exist in the ESP32. Wondering if that's intentional or an oversight?
Anyway, I copied the file and included it in one of my ESP32 projects. It compiles and works just fine:
…/esp8266\hardware\esp8266\3.1.1\cores\esp8266
It contains the Unix time zone codes ('TZ' environment variable) for hundreds of locations around the world. They're defined with human-readable macros. For example:
Code: Select all
#define TZ_America_Chicago PSTR("CST6CDT,M3.2.0,M11.1.0")
#define TZ_Europe_London PSTR("GMT0BST,M3.5.0/1,M10.5.0")
#define TZ_America_New_York PSTR("EST5EDT,M3.2.0,M11.1.0")
Anyway, I copied the file and included it in one of my ESP32 projects. It compiles and works just fine:
Code: Select all
configTzTime(TZ_America_New_York, ntpServer1, ntpServer2);