What is my server timezone?

Luca Spiller
Head of Engineering
January 07, 2024

As server administrators, one often-overlooked but crucial piece of information is the server's timezone. Accurate timekeeping is not only essential for synchronization across distributed systems but also for managing scheduled tasks, debugging, and ensuring a seamless user experience. In this guide, we will explore how to uncover the mystery of your server's timezone, whether it's a Linux powerhouse or a Windows workhorse.

Identifying the timezone on a Linux server

Our journey begins in the heart of Linux - the command line. You'll need ssh access to the server, and then you can run the date command:

$ date
Mon  7 Jan 14:49:35 UTC 2024

$ date
Mon  7 Jan 09:52:29 EST 2024

This simple command reveals not only the current date and time but also the timezone the system is set to - the UTC and EST part.

The abbreviations are useful, but it's easy to confuse them (CEST is in Europe and CST is in the US). Let's print out the timezone offset in hours:

$ date +"%Z %z"
EST -0500

The magic lies in the formatting options. %Z provides the timezone abbreviation (UTC), while %z prints the time offset from UTC. The - sign indicates the timezone is behind UTC (more West), while the + sign indicates it is ahead of UTC (more East).

Changing the system timezone

It's often useful to set the timezone of servers to where you are based, rather than where they are located. We are based in London, so we set all our servers to UTC. This allows us to easily compare log and event timestamps across servers in different geographic regions without having to convert timezones in our head. Using a single timezone also makes it easier to schedule tasks and debug issues. Note that we use UTC rather than the London timezone, so we don't have to deal with daylight savings time (DST) issues.

To change the timezone on many Linux distributions, you can use the timedatectl command. This applies to Ubuntu, Mint, Debian, Fedora - for other distributions, check what command they recommend to use. First we need to find a list of timezones which we can obtain with the timedatectl list-timezones command:

$ timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
...

This will provide a long list of timezones. You can press Ctrl F to scroll down, Ctrl B to scroll up, and Ctrl C to exit. It contains geographic timezones such as Europe/London as well as non-geographic timezones such as UTC.

Find the exact name of your desired timezone and copy it, then run timedatectl set-timezone [timezone name].

$ timedatectl set-timezone Europe/London

You can then verify it has changed by running the timedatectl command without any arguments:

$ timedatectl
               Local time: Tue 2024-01-09 09:06:15 UTC
           Universal time: Tue 2024-01-09 09:06:15 UTC
                 RTC time: Tue 2024-01-09 09:06:15
                Time zone: Europe/London (UTC, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: yes

That's it! The new timezone will be persisted when you reboot. You may want to reboot the server now to ensure all services (logs, web servers, databases) pick up the timezone change.

Identifying the timezone on a Windows server

For Windows aficionados, discovering the timezone is a breeze through the Date & Time settings.

  • Open the Start menu and click on "Settings" (the gear icon).
  • Navigate to "Time & Language."
  • Click on "Date & Time" in the left sidebar.
  • Scroll down to the "Timezone" section, where the configured timezone will be displayed.

Conclusion

In conclusion, understanding and controlling the timezone settings on servers are essential aspects of efficient system administration. Whether navigating Linux servers through commands like date and timedatectl or seamlessly finding timezone information on Windows servers through system settings, this article provides a comprehensive guide for server administrators. Prioritizing precise timekeeping contributes not only to synchronized operations but also facilitates effective debugging and streamlined user experiences across diverse server environments.