Checking the Current Timezone
timedatectl is a command-line utility that allows you to view and change the system’s time and date. It is available on all modern systemd-based Linux systems, including Ubuntu 20.04.
To print the current system’s timezone invoke the timedatectl without any arguments:
timedatectl
The output below shows that the system’s timezone is set to “UTC”:
Local time: Wed 2020-05-06 19:33:20 UTC Universal time: Wed 2020-05-06 19:33:20 UTC RTC time: Wed 2020-05-06 19:33:22 Time zone: UTC (UTC, +0000) System clock synchronized: yes NTP service: active RTC in local TZ: no
Changing the Timezone Using the timedatectl Command
Before changing the timezone, you’ll need to find out the long name for the timezone you want to use. The timezones are using “Region/City” format.
To list all available time zones, you can either list the files in the /usr/share/zoneinfo directory or invoke the timedatectl command with the list-timezones option:
timedatectl list-timezones
... America/Montevideo America/Nassau America/New_York America/Nipigon America/Nome America/Noronha ...
Once you identify which time zone is accurate to your location, run the following command as sudo user:
sudo timedatectl set-timezone your_time_zone
For instance, to change the system’s timezone to Europe/Bucharest:
sudo timedatectl set-timezone Europe/Bucharest
Invoke the timedatectl command to verify the changes:
timedatectl
root@ubuntuserver:/# timedatectl Local time: Du 2022-09-18 09:29:27 EEST Universal time: Du 2022-09-18 06:29:27 UTC RTC time: Du 2022-09-18 06:29:27 Time zone: Europe/Bucharest (EEST, +0300) System clock synchronized: yes NTP service: active RTC in local TZ: no root@ubuntuserver:/#
Ubuntu server 22.04 – time format 24 hours on shell with date command
The easiest way is to change LC_TIME variable to locale that uses desired time formatting. en_GB uses 24h clock for example. You can set it system-wide using localectl:
localectl set-locale LC_TIME="ro_RO.UTF-8"
Then, you have to relogin to see changes.