After HW reset (button or power reconnect) I get the correct NTP shift, but when I use ESP.restart() via MQTT I get the correct time without 3 3 HRS shift due to Tz. What happens after SW reset that behaves in such manner and how to fix it?
bool myIOT2::_startNTP(const char *ntpServer, const char *ntpServer2)
{
unsigned long startLoop = millis();
while (!_NTP_updated() && (millis() - startLoop < 20000))
{
#if defined(ESP8266)
configTime(TZ_Asia_Jerusalem, ntpServer2, ntpServer); // configuring time offset and an NTP server
#elif defined(ESP32)
configTzTime(TZ_Asia_Jerusalem, ntpServer2, ntpServer);
#endif
delay(1000);
}
if (!_NTP_updated())
{
return 0;
}
else
{
return 1;
}
}
bool myIOT2::_NTP_updated()
{
return now() > 1640803233;
}