ESP32 NTP Time Sync Returns Wrong Date
DodaTech
Updated 2026-06-26
1 min read
In this tutorial, you'll learn about ESP32 NTP Time Sync Returns Wrong Date. We cover key concepts, practical examples, and best practices.
The Problem
ESP32 time synchronization via NTP returns a date/time that is incorrect, often showing year 1970.
Quick Fix
Wrong
configTime(0, 0, "pool.ntp.org");
time_t now = time(nullptr);
Serial.println(ctime(&now));
Thu Jan 1 00:00:05 1970
(Time never synced)
Right
configTime(-5 * 3600, 3600, "pool.ntp.org", "time.nist.gov");
delay(5000);
time_t now = time(nullptr);
while (now < 100000) {
delay(1000);
now = time(nullptr);
}
Serial.println(ctime(&now));
Fri Jun 26 10:30:00 2026
(Correct current time)
Prevention
Wait for NTP sync with a timeout loop (check when time > 100000). Use multiple NTP servers as fallback. Set correct timezone offset and DST. Allow 5-10 seconds for initial sync. Call configTime() after Wi-Fi connects.
DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro