Skip to content

ESP32 NTP DST Transition Not Handled

DodaTech Updated 2026-06-26 1 min read

In this tutorial, you'll learn about ESP32 NTP DST Transition Not Handled. We cover key concepts, practical examples, and best practices.

The Problem

ESP32 time does not account for Daylight Saving Time changes or transitions at wrong dates.

Quick Fix

Wrong

configTime(-5 * 3600, 0, "pool.ntp.org");  // No DST
Time is off by 1 hour during DST period.
setenv("TZ", "EST5EDT,M3.2.0/2,M11.1.0/2", 1);
tzset();
configTime(0, 0, "pool.ntp.org");
time_t now = time(nullptr);
Serial.printf("Local time: %s", asctime(localtime(&now)));
Local time: Fri Jun 26 10:30:00 2026
(DST applied automatically)

Prevention

Use POSIX timezone string with DST rules instead of manual offsets. Set TZ environment variable with tzset() before configTime(). Verify DST transition rules for your region. Test near DST changeover dates.

DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.

FAQ

### What POSIX timezone string should I use?

Format: STDoffsetDSToffset[,start[,end]]. Example: EST5EDT for US Eastern. Find strings for your region online.

Does ESP32 support the Olson timezone database?

No. ESP32 uses POSIX timezone strings, not Olson (IANA) names like America/New_York. Use the POSIX format.

What happens during DST transition?

At the transition, time jumps forward or backward by 1 hour. Code that schedules events should use UTC internally.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro