How to Check and Set Timezone in Ubuntu 20.04

Overview

In this tutorial, you will learn how to check and set the timezone in Ubuntu 20.04 using the timedatectl command.

There are a variety of ways of checking your timezone, from using the date command to the timedatactl command. However, setting your timezone has been greatly simplified and improved with the timedatactl command.

The timedatectl command allows you to output detailed information about your system’s date in time, from NTP info to comparisons between your date with the UTC date.

While we’ve limited the scope of this tutorial to strictly being about setting your timezone, the timedatectl has additional functionality that is very useful for configurations around time and date.

Checking Your Current Timezone

The currently configured timezone is set in the /etc/timezone file. To view your current timezone you can cat the file’s contents.

cat /etc/timezone
Etc/UTC

Another method is to use the date command. By giving it the argument +%Z, you can output your system’s current time zone name.

date +%Z
UTC

To get the timezone name and offset, you can use the data command with the +"%Z %z" argument. The uppercase Z prints the timezone name, while the lowercase z outputs the time offset.

date +"%Z %z"
UTC +0000

The timedatectl command be used to get more details about your system’s current time and date configurations.

timedatectl
               Local time: Sat 2020-09-05 03:09:26 UTC
           Universal time: Sat 2020-09-05 03:09:26 UTC
                 RTC time: Sat 2020-09-05 03:09:26    
                Time zone: Etc/UTC (UTC, +0000)       
System clock synchronized: yes                        
              NTP service: active                     
          RTC in local TZ: no     

Setting Your Timezone

To set your timezone the timedatectl command will be used. Before you set your new timezone you may want to know what timezones are available. You can list all available timezones using the timedatectl list-timezones command.

timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Algiers
Africa/Bissau
Africa/Cairo
Africa/Casablanca
Africa/Ceuta
Africa/El_Aaiun
Africa/Johannesburg
Africa/Juba
Africa/Khartoum
Africa/Lagos
Africa/Maputo
Africa/Monrovia
Africa/Nairobi
Africa/Ndjamena
Africa/Sao_Tome
...

The timezone list is very extensive. To narrow the list down to only your region you can pipe the results to the grep command. For example, to narrow our results to only the Americas, we would run the following command.

timedatectl list-timezones | grep America
...
America/Santiago
America/Santo_Domingo
America/Sao_Paulo
America/Scoresbysund
America/Sitka
America/St_Johns
America/Swift_Current
America/Tegucigalpa
America/Thule
America/Thunder_Bay
America/Tijuana
America/Toronto
America/Vancouver
America/Whitehorse
America/Winnipeg
America/Yakutat
America/Yellowknife

Once you know the time zone you want to set your Ubuntu server to, you use the timedatactl set-timezone command to set it.

sudo timedatectl set-timezone America/Toronto

and then confirm your changes were applied by running the timedatactl command.

timedatectl
               Local time: Fri 2020-09-04 23:30:58 EDT 
           Universal time: Sat 2020-09-05 03:30:58 UTC 
                 RTC time: Sat 2020-09-05 03:30:59     
                Time zone: America/Toronto (EDT, -0400)
System clock synchronized: yes                         
              NTP service: active                      
          RTC in local TZ: no