How to Use GMT Offsets in Your Arduino Projects for Accurate Time Synchronization

, ,

When working with time-sensitive projects in Arduino or ESP32, accurate time synchronization is crucial. Whether you’re building a clock, weather station, or a global time-tracking system, adjusting for the local time zone is essential for ensuring your project displays the correct time. GMT (Greenwich Mean Time) offsets are a key factor in achieving this. In this post, we’ll explore how you can use GMT offsets, including both the hour and second values, to adjust the time in your projects, ensuring that your system reflects the correct local time for different countries around the world. Whether you’re in India, the United States, or Australia, understanding and applying these offsets can significantly enhance your project’s accuracy and usability.

GMT Offsets for Various Countries: This detailed list provides GMT offsets for countries worldwide. You can use the offset in seconds directly in your code to adjust the time for each country accurately.

CountryTime ZoneOffset in HoursOffset in Seconds
United KingdomGMT / UTC00
United States (EST)GMT-5-5-18000
United States (PST)GMT-8-8-28800
IndiaGMT+5:305.519800
JapanGMT+9932400
ChinaGMT+8828800
Australia (AEST)GMT+101036000
Russia (Moscow)GMT+3310800
Brazil (BRT)GMT-3-3-10800
GermanyGMT+113600
FranceGMT+113600
South AfricaGMT+227200
New ZealandGMT+121243200
ArgentinaGMT-3-3-10800
Mexico (CST)GMT-6-6-21600
UAEGMT+4414400
Saudi ArabiaGMT+3310800
TurkeyGMT+3310800
South KoreaGMT+9932400
PakistanGMT+5518000
EgyptGMT+227200
ThailandGMT+7725200
Indonesia (Jakarta)GMT+7725200
Canada (CST)GMT-6-6-21600
ItalyGMT+113600
PhilippinesGMT+8828800
SingaporeGMT+8828800

How to Use These GMT Offsets: You can directly use the corresponding Offset in Seconds for accurate time synchronization in your Arduino or ESP32 projects. This is especially useful when your project involves displaying or logging time in specific locations around the world.

For example:

  • India (GMT+5:30): The offset is 19800 seconds.
  • United States (EST, GMT-5): The offset is -18000 seconds.

Applying the GMT Offset in Arduino Code: Using the NTPClient Library, you can easily sync time with an NTP server and adjust it based on your country’s GMT offset. The offset is provided in seconds.

Code Example:

// NTP Client Setup
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org", 19800, 3600000); // Timezone offset (19800 seconds = UTC +5:30)

// For example, if your project is in India (GMT+5:30)
int gmtOffset_sec = 19800; // Offset for India (GMT+5:30)

// For United States (EST, GMT-5)
// int gmtOffset_sec = -18000; // Offset for United States (EST, GMT-5)

// Use the timeClient.setTimeOffset() function to adjust the time
timeClient.setTimeOffset(gmtOffset_sec);


By setting gmtOffset_sec correctly, you ensure that the time returned by the NTP server is adjusted to the correct local time based on your project’s location.


Example Time Calculation: Let’s say you’re working on a project that needs to display the correct time in India (IST, GMT+5:30). India’s offset is 19800 seconds (5.5 hours ahead of GMT), so you would use timeClient.setTimeOffset(19800) in your code.

For a project located in United States Eastern Standard Time (EST), the offset is -18000 seconds (5 hours behind GMT). In this case, you would use timeClient.setTimeOffset(-18000).


Summary: Accurate time synchronization is essential for your Arduino or ESP32 projects. By using the gmtOffset_sec variable and applying the correct offsets based on the country or time zone, you can ensure your project reflects the correct local time for a variety of locations across the globe. Use the table above to select the right offset for your project, and adjust your code accordingly. With this method, you can easily manage time across different time zones, making your projects more versatile and globally accessible.