How to Set or Change Time, Date, and Timezone in Ubuntu

October 30, 2024

Introduction

Modern operating systems synchronize time using the Network Time Protocol (NTP). NTP communicates with time servers connected to highly precise atomic clocks and downstream servers that distribute time globally.

Occasionally, you may need to manually synchronize time with NTP servers due to a network disruption or misconfiguration.

This guide shows you how to check and adjust Ubuntu's time, date, and timezone.

Setting the time, data, and timezone in Ubuntu.

Prerequisites

Display Current Time, Date, and Timezone in Ubuntu

Most Linux distributions, such as Ubuntu, Fedora, Debian, and Arch, include the timedatectl utility. Access the command line and enter the timedatectl command to display the current time and date information:

timedatectl
Checking date, time, and timezone settings in Ubuntu.

The output provides the local time and date, universal time (UTC), and configured timezone and informs you if time synchronization is enabled.

Change Time, Date, and Timezone in Ubuntu Using timedatectl

You can also use the timedatectl command to edit time, date, and timezone settings in Ubuntu.

Set Timezone in Ubuntu Using timedatectl

To synchronize a system with a timezone of your choosing:

1. Enter the following command to list the names of available timezones:

timedatectl list-timezones
List available timezones in Ubuntu.

2. The timezone list is extensive and sorted alphabetically. Use the grep command to filter the list by keyword:

timedatectl list-timezones | grep [keyword]
Filter timezone list in Ubuntu.

Substitute [keyword] for any keyword you wish, such as America, Asia, or New_York.  If you get an error, double-check your spelling and ensure you use capital letters correctly.

3. Use the following command to set the timezone:

timedatectl set-timezone Region/Location

Replace Region/Location with a name from the timezone list.

Set Universal Time (UTC) in Ubuntu Using timedatectl

Coordinated Universal Time (UTC) is used to synchronize time across different time zones. This is especially useful in the cloud and containerized environments, as it eliminates issues caused by local time shifts, like daylight saving time. Synchronize your system with UTC using the following command:

timedatectl set-timezone UTC

There is no immediate output; however, you can check the applied settings with timedatectl.

Set system timezone to match UTC timezone.

Note: GMT and Zulu Time are often used to refer to UTC. They are equivalent terms when fractions of a second are not relevant.

Sync Time with NTP in Ubuntu Using timedatectl

Set the Ubuntu system to synchronize with NTP time servers using the following command:

timedatectl set-ntp yes

The system does not provide immediate output. Use the timedatectl command to verify the changes have been applied.

Change Time in Ubuntu Using timedatectl

If you want to adjust the time manually, you must turn off NTP synchronization first:

timedatectl set-ntp no

To set the time to your specifications, use the following command:

timedatectl set-time 21:45:53

The time format is HH:MM:SS (Hours:Minutes:Seconds).

Change Date in Ubuntu Using timedatectl

Ensure that the automatic NTP synchronization is turned off:

timedatectl set-ntp no

Use the set-time option to define the date on the system:

timedatectl set-time 2024-10-28

The date format is YYYY-MM-DD (Year-Month-Day).

Change Time, Date, and Timezone in Ubuntu via GUI

Some users may prefer to adjust system settings through the Ubuntu graphical interface in a user-friendly and interactive environment.

To modify time, date, and timezone settings via the Ubuntu GUI:

1. Open the Show Applications menu in the bottom-left corner.

2. Type Date & Time in the search field and select the Date & Time option.

Access the Date & Time panel in the Ubuntu GUI.

The Date & Time panel contains all the options for adjusting the system's time, date, and timezone settings.

Options in the Ubuntu Date & Time panel.

Set Timezone in Ubuntu Using the GUI

To change the timezone in the Ubuntu GUI:

1. Access the Time & Date panel.

2. Disable the Automatic Time Zone option.

3. Click the Time Zone tab.

Changing the timezone in the Ubuntu GUI.

4. Search for your city or region and select the desired option in the Select Time Zone popup.

Select a new timezone on the Ubuntu GUI.

Close the popup window and exit the Settings app.

Set Universal Time (UTC) in Ubuntu Using the GUI

Depending on the version, Ubuntu may not explicitly list Coordinated Universal Time (UTC) as a timezone. For example, this is true in Ubuntu 24.04. However, it can be set indirectly by selecting London or Reykjavik, which follow UTC. To synchronize time with UTC in Ubuntu:

1. Access the Date & Time panel.

2. Turn off the Automatic Time Zone toggle.

3. Click the Time Zone field.

Setting timezone to UTC in Ubuntu.

4. Search for and click London or Reykjavik in the list.

Setting the Ubuntu timezone to London UTC time.

Your system is now set to follow UTC.

Sync Time with NTP in Ubuntu Using the GUI

To automatically synchronize your system clock with NTP:

1. Access the Date & Time panel in the Settings app.

2. Enable the Automatic Date & Time toggle.

Configure Ubuntu to sync time with NTP servers.

The system now syncs time with NTP servers as long as the feature is turned on and connected to the internet.

Change Time and Date in Ubuntu Using the GUI

To change the time and date within the Ubuntu GUI:

1. Access the Date & Time panel.

2. Disable the Automatic Date & Time option.

3. Click the Date & Time field.

Changing the date and time in the Ubuntu GUI menu.

4. Use the corresponding fields and buttons in the popup to adjust the time, month, day, and year.

Adjust the system time and date in the Ubuntu GUI.

Close the popup and exit the Settings menu. The new settings are applied immediately.

Hardware Clock vs. System Clock

Modern devices maintain two types of clocks to keep track of time. The system clock is managed by the device's operating system, for example, Ubuntu. It synchronizes with online time servers when connected to the internet. Timestamps for files, scheduled tasks, and logs are based on this clock.

The hardware clock or Real-Time Clock (RTC) helps the system track time when disconnected from the internet or powered off. It uses a battery and a quartz crystal oscillator to maintain time without external power or a network connection. When the system boots up again, it reads the hardware clock to initialize the system clock. Once the system is up and running, it can synchronize with NTP servers to correct potential inaccuracies.

How to Sync Hardware Clock in Ubuntu

Hardware clocks can drift and lose accuracy, especially if a system has been turned off or disconnected from a network for a long time. Occasionally, it may be necessary to align the hardware clock (RTC) with Coordinated Universal Time (UTC).

Align Hardware Clock with UTC

Enter the following command to set the hardware clock to use UTC:

timedatectl set-local-rtc 0

This is the recommended setting for most systems. NTP servers synchronize with UTC, and operating systems expect the hardware clock to store time in UTC.

There is no confirmation message that the change has been applied. You can verify the change using the timedatectl command:

timedatectl
Configure RTC clock in Ubuntu to align with UTC clock.

The output confirms that the RTC time is using UTC.

Set Time, Date, and Timezone in Older Ubuntu Versions

Older Ubuntu versions, such as Ubuntu 14.04 or earlier, may not support the timedatectl utility. If timedatectl is not available, use the following commands to manage system and hardware clocks from the command line. The commands work on both older and newer Ubuntu versions.

Display Date and Time

Use the date command to display the current date and time of the operating system:

date
Using the date command in Ubuntu.

Adjust Date

To change the system date, type:

sudo date -s "YYYY-MM-DD"
Changing the date in older Ubuntu version.

Replace YYYY-MM-DD with the desired Year-Month-Day.

Adjust Time

To change the system time, enter:

sudo date -s "HH:MM:SS"
Changing the time in older Ubuntu versions.

Replace HH:MM:SS with the desired Hour:Minute:Second. The time and date can be modified in a single command:

sudo date -s "YYYY-MM-DD HH:MM:SS"

This is more convenient when you need to define both the date and time at once.

Display RTC Date and Time

Display the time kept by the hardware clock (RTC) with any of the following commands:

sudo hwclock -r

or

sudo hwclock --show

or

sudo hwclock --show --verbose

Note: Some versions may not support the --verbose option, and it may not work on a virtual machine.

Display RTC Time in UTC Format

To display the hardware clock time in UTC format, enter:

sudo hwclock --show --utc

Change RTC Time

Change the time kept by the hardware clock using the following command:

sudo hwclock --set --date "YYYY-MM-DD HH:MM:SS"

Replace YYYY-MM-DD with the desired Year-Month-Day, and HH:MM:SS with the desired Hour:Minute:Second.

Sync OS Time with RTC

To set the system clock based on the hardware clock (RTC), run:

sudo hwclock --hctosys

Sync RTC Time with OS

To synchronize the hardware clock (RTC) with the system clock, use:

sudo hwclock --systohc

Conclusion

The article showed you how to set the time, date, and timezone on your Ubuntu system. The best course of action for most systems is to synchronize time with NTP servers automatically.

If running a MySQL server, also learn how to configure the MySQL server timezone.

Was this article helpful?
YesNo
Vladimir Kaplarevic
Vladimir is a resident Tech Writer at phoenixNAP. He has more than 7 years of experience in implementing e-commerce and online payment solutions with various global IT services providers. His articles aim to instill a passion for innovative technologies in others by providing practical advice and using an engaging writing style.
Next you should read
How to Get the Current Date and Time in Python
March 12, 2024

The article shows you how to create a basic Python script that displays the current date and time. Find out how to use the datetime and time modules to format the information you need.
Read more
How to Use JavaScript to Get the Current Date and Time
December 6, 2023

This guide will walk you through using Javascript to get a date from a client. You will see how to write a script to retrieve the current date and time, handy for creating a timestamp and writing to a log file.
Read more
How to Check Memory Usage in Linux via CLI and GUI
March 28, 2024

Learn the most commonly used commands to check memory usage in Linux. The guide also provides detailed explanations on how to interpret the results.
Read more
How to Check CPU Utilization in Linux with Command Line
March 6, 2024

You have probably noticed your Linux OS slowing down, especially when working harder. Understanding CPU processor usage is critical for overall performance measurement.
Read more