Setting Date, Time, and Time Zone on Ubuntu Linux

Date and time are two critical 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, system, and network.

Hardware time

When you purchase a computer, the motherboard of your computer comes with a pre-installed and configured chip-based clock. A CMOS battery powers this clock. 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 you see on your operating system's desktop come from this clock.

During the Linux installation, the 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 choose his location.

default time zone

The installation wizard installs the system clocks and uses the user's geographical location to calculate and set the current time. It calculates time in 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 present, the operating system uses the system time as the network time. From these types, it is the most accurate and reliable time. However, configuring the network time is a complex 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 and the system time.

Viewing date and time

By default, Ubuntu always shows the date and time on the desktop. If you click the date and time, a new window opens. It displays the current date in the calendar along with today's events.

displaying date and time

The date command displays the current date time on the command prompt.

$date

date command

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

$sudo hwclock --show

hwclock command

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.

starting dash

The right pane of the opened settings window allows us to configure the date and time. It includes settings for network and system time. We can use only one time. To use the system time, we must turn off the network time. This tool does not allow us to change the hardware time.

date and time

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

setting date

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

timze zone

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

time format

Any change made in settings applies immediately.

Changing or updating the date and time on the command prompt

The following command updates or changes the date and time.

$sudo date [month-day-hour-minutes-year]

There is no space between arguments.

For example, the following command sets the system's time to 05 April 2025 at 11:30 AM.

$sudo date 040511302025

The following image shows the above command with the output.

date command

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 2025 at 10:30:00 AM.

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

set hardware time

Syncing times

You can configure the system to sync system time from hardware time and vice versa. The following command sets the system time from the hardware time.

$sudo hwclock --hctosys

hwclock command

The following command sets the hardware time from the system time.

$sudo hwclock --systohc

The following image shows an example of the above command.

hwclock command

Conclusion

Setting and updating the system time are essential tasks. In this tutorial, I explained how to perform these tasks on Ubuntu using a GUI and command line tool.

ComputerNetworkingNotes Linux Tutorials Setting Date, Time, and Time Zone on Ubuntu Linux

We do not accept any kind of Guest Post. Except Guest post submission, for any other query (such as adverting opportunity, product advertisement, feedback, suggestion, error reporting and technical issue) or simply just say to hello mail us ComputerNetworkingNotes@gmail.com