Setting Date, Time, and Time Zone on Ubuntu Linux

This tutorial explains how to display or set the date, time, and time zone on Ubuntu Linux. Learn how to change or sync the system time and the hardware time manually.

Date and time are two important settings of any computer system. Many features and functions (such as scheduled maintenance, backup, software updates, login hours, and downtime) depend on both settings.

A computer system maintains three types of time: hardware time, system time, and network time.

Hardware time

When you purchase a computer, the motherboard of your computer comes with a pre-installed and configured chip-based clock. This clock is powered by a CMOS battery. Your computer\’s hardware time depends on this clock.

System time

When you install an operating system, based on your selections and several other settings, the operating system automatically installs and configures a system clock for you. The date and time which you see on the desktop of your operating system arrive from this clock.



During the Linux installation, the installation wizard asks the user to select the user\’s geographical location. The following image shows a sample example of how the wizard prompts the user to select his location.

user location

The installation wizard installs the system clocks and uses the user\’s geographical location and the current hardware time to calculate and set the current system time. Linux time is based on the number of seconds elapsed since 1 January 1970.

Network time

When you connect your computer with other computers in a network or connect your computer to the Internet, the operating system uses the network time. If the network time is not configured, the operating system uses the system time as the network time.

From these types, the network time is considered to be the most accurate and reliable time. But configuring the network time is a bit complicated task. Usually, you do not need to configure the network time on a standalone system. On a standalone system, the system time is sufficient.

In this tutorial, we will understand how to view, configure, and manage the hardware time and the system time. We will understand the network time in the next part of this tutorial.

Viewing date and time



By default, the date and time are always visible on the desktop screen of Ubuntu. If you click the date and time, a new window opens that displays the current date in the calendar along with today\’s events.

The following image shows a sample of this.

displaying date and time

To view date and time on command prompt, use the date command.

The following image shows the date command with the output.

viewing date on command prompt

The date command displays the system time. To view the hardware time, use the following command.

$sudo hwclock --show

The following image displays the output of the above command.

viewing hardware time or clock

Changing or updating the system time

The easiest way to change or update the system time is to change it from the graphical tool. To use the graphical tool, click the Dash icon and type \’date\’ in the search box of the opened window.

The following image shows these steps.

opening date and time settings

The right pane of the opened settings window allows us to configure the date and time. It includes settings for both types of time: network time and system time.

Key points
  • This graphical tool does not allow us to change the hardware time.
  • From both types: the system time and network time, you can use only one type at a time. If you want to use the system time, then you have to turn off the network time.

The following image shows the opened window.

clock setting window

To adjust or set time, click the time option. This will open a new window that allows us to change or set the new time.

The following image shows this option.

setting or changing time on ubuntu

To change or localize the time zone, click the time-zone option. This will open a map of the world in a new pop-up window. To select a new time zone, click the respective country on the map.

The following image shows a sample of this.

changing time zone

To change the time format, use the time format option. To view time in 12 hours format, select the AM/PM option.

The following image shows an example of this.

changing time format

Any change made in settings applies immediately.

Changing or updating date and time on the command prompt

To update or change date and time from the command prompt, use the following command.

$sudo date [month day hour minute year]

Don\’t use any space between arguments.

For example, the following command sets your system\’s time to 05 April 2020 at 11:30 AM.

$sudo date 040511302020

The following image shows the above command with the output.

setting date and time from the command line

To set or adjust the hardware time, use the following command.

$sudo hwclock --set --date \"month/date/year hour:minute:second\"

For example, the following command sets the hardware clock to 06 April 2020 at 10:30:00 AM.

$sudo hwclock --set --date \"06/04/20 10:30:00\"

The following image shows the above command with the output.

setting hardware clock

Syncing times

Instead of setting the time manually, you can also use the system time to set the hardware time and the hardware time to set the system time.

To set the system time from the hardware time, use the following command.

$sudo hwclock --hctosys

The following image shows an example of the above command.

syncing hardware time from the system time

To set the hardware time from the system time, use the following command.

$sudo hwclock --systohc

The following image shows an example of the above command.

syncing system time from hardware time

That\’s all for this tutorial. In the next part of this tutorial, we will understand how to configure and manage the network time. If you like this tutorial, please don\’t forget to share it with friends through your favorite social networking site.