Auto Timezone Detection

Steven Lin  |  Senior Software Engineer

ABSTRACT — To record data and operate normally, devices must display the accurate time for different countries and regions. In order to solve this problem, we have implemented a mechanism to automatically detect the time zone, allowing the device to get the time zone that corresponds to the current network location.

I – Introduction

The time zone is the same time definition of the region on Earth. In 1863, the concept of time zone was first used. The time zone partially solves this problem by setting a standard time for the region.

The machines on the network basically use NTP (Network Time Protocol) to synchronize their clocks over the Internet. There are many NTP servers on the network that can synchronize the correct time.

II – How To Get Timezone

In order to synchronize the correct time with the NTP server, providing a corresponding time zone is the first necessary step. To determine a time zone, we must have latitude and longitude.

We use the IP (Internet Protocol) address as an anchor point to obtain latitude and longitude, which can then help us determine the correct time zone.

III – Manual To Automatic

Before we can implement the automatic time zone detection mechanism, we must manually set or select the time zone of the device through the GUI. While it is inconvenient, setting the time manually will allow the device to automatically get the time, removing the need to set it manually. Since it is fastest and most convenient for the device itself to automatically query the time zone via the network, we implemented a mechanism to automatically detect the time zone.

IV – Timezone Detection Mechanism

Because some methods on the network achieve only partial results, we have developed a complete detection mechanism that requires only three conditions:

1. List of global time zones

2. IP address

3. The server that can check the time zone after giving latitude and longitude

The first two pieces of information can be provided through prepreparation and the device itself. There are many servers on the Internet that provide time zone check services. We can get results by providing the corresponding information to the server. Then update the acquired time zone information to the device, and the implementation of this method is completed.

V – Conclusion

The way to set the time zone only through the GUI can also be replaced by automatic acquisition. With this automatic detection time zone mechanism, the device can automatically get the correct time. It is more convenient for the data record and system operation.


1. 2020. Pool.Ntp.Org: The Internet Cluster Of Ntp Servers.
2. Google Developers. 2020. Public NTP|Google Developers.

Download PDF >

See all Technical Papers >