# ESP32 NTP time is wrong: set the time zone for India \(UTC+5:30\)

> Fix the ESP32 clock showing the wrong hour: configTime offsets, India Standard Time is 19800 seconds from UTC, and waiting for the sync.

Canonical: https://roboticsengineering.in/fix/esp32-ntp-time-wrong-timezone-india/ | Published: 2026-11-03 | Updated: 2026-11-04

**India Standard Time is UTC plus 5 hours 30 minutes, which is 19800 seconds.** Pass that to configTime as the offset.

## What the message means

NTP gives UTC. The board adds the offset you set. With an offset of zero the time shows UTC.

## Fix it in this order

1. Call configTime(19800, 0, “pool.ntp.org”) after Wi-Fi connects. India has no daylight saving, so the second value is 0.
2. Wait until getLocalTime returns true before you read the time.
3. Check that Wi-Fi is connected, since NTP needs the internet.
4. Use a second server if the first does not answer.
5. Format the time with strftime and print it to check.

## Why it happens

NTP servers send the time in UTC, which is a single reference time with no regional offset. The ESP32 stores that value and applies the offset you configure, along with any daylight saving rule. Without an offset, every clock reads UTC. India is 5 hours and 30 minutes ahead of UTC, so the displayed hour is 5.5 hours behind local time, and the date can be wrong near midnight.

The configTime call is not instant: the clock starts at the Unix epoch, then jumps forward once a server answers. Reading the clock too early returns 1970 or an old date. The ESP32 needs working internet access on the same Wi-Fi network to reach an NTP server, and a blocked UDP port 123 keeps it from syncing. The offset is given in seconds, so a value written in hours or minutes is a common slip.

## If you see this, do this

| You see | Do this |
| --- | --- |
| Hour is off by 5 and a half | Offset not set. |
| Time stays at 1970 | NTP not synced yet. |

## Confirm the fix

1. Print the offset you passed, 19800 seconds, then compare the printed local hour with a phone clock set to India time.
2. Call getLocalTime and print the year; a value of 1970 means sync has not happened, so wait a few seconds and retry.
3. Print the UTC hour with gmtime_r and the local hour with localtime_r in one sketch; the difference should be exactly 5.5 hours.

**Common mistake:** Readers often assume that naming a timezone once fixes everything, but the simple configTime call takes a numeric offset, so a wrong number or a missing time sync still shows the wrong time.

## Related

[Wi-Fi will not connect](https://roboticsengineering.in/fix/esp32-wifi-wont-connect/), [HTTP error codes](https://roboticsengineering.in/fix/esp32-httpclient-negative-error-code/).

Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.
