top of page

How to Set the Date and Time on Linux

Keeping software on your device up to date is an important part of having a robust and secure system, but even more important is having an up-to-date time and date.

Accurate time and date on a system not only tells you the correct time but also allows you to execute automated tasks as expected and connect to services over the internet seamlessly.

This guide will show you how to review, adjust, and configure the time and date on Linux from the command line using the timedatectl command.

How Time Is Managed on Linux

In order to keep accurate time, Linux uses two different kinds of clocks :

  • A real-time clock (RTC) or hardware clock integrated into your computer's circuit board which runs independently of the operating system. The clock still runs even when your operating system is shut down, rebooting, or hibernating.

  • A system clock, also popularly known as a software clock. Maintained by the Linux kernel, the system clock depends on the real-time clock to get its initial time when your Linux OS is booting up.

By default, your system time is kept in the Universal Coordinated Time (UTC) format. Your Linux system then converts the UTC time to the correct local time based on your region or time zone. The local time is what's displayed on the desktop.

Listing Time and Date Information

One of the most important tasks you should be able to carry out when it comes to configuring the time on Linux is to be able to list and review the current time on your system.

To display time and other configuration parameters, simply run the timedatectl command without any parameters as follows:


The command displays the system's local time, the UTC time, and the real-time clock. The time zone and other important time-related parameters are also listed in the output.

How to Adjust the Time on Linux

To set or change the time, use the timedatectl command together with the set-time subcommand.

sudo timedatectl set-time hh:mm:ss

Note: You need to have elevated privileges to adjust the time or date.

In the aforementioned command, the hh stands for hours, mm for minutes, and ss for seconds.

The time you specify should be in the 24-hour format.

For example, to set the time to 12 o'clock midnight, run the following command:

sudo timedatectl set-time 00:00:00

The command updates both the real-time clock and the system or software clock. However, you will fail to change the time or date if the Network Time Protocol (NTP) is enabled on your system.

How to Enable/Disable NTP

The Network Time Protocol helps you in making sure that your time is synchronized with a remote server based on your time zone or region.

To disable NTP on Linux, run the following command:

sudo timedatectl set-ntp false

To reactivate or enable NTP, simply run:

sudo timedatectl set-ntp true

Once enabled, the system will automatically adjust and synchronize the time with the configured server time.

Note: The set-ntp subcommand will not work if your system doesn't support NTP.

How to Set the Date on Linux

To change the date on your computer, you can run the timedatectl command with the set-time subcommand in the following format:

sudo timedatectl set-date YYYY-MM-DD

where YYYY is the year, MM is the month, and DD is the day.

For example, to change the date to January 1, 2000, issue the following command:

sudo timedatectl set-time "2000-01-01 23:00:01"

Note that we've also specified the time because when you only specify the date, timedatectl will automatically set the time to 00:00 i.e. 12 midnight.

Changing Your Time Zone

Before you can proceed and change the time zone on your PC, it is important that you know how to list or view available time zones.

timedatectl list-timezones

Use the F key on your keyboard to scroll forward and the B key to scroll backward through the listed timezones. Alternatively, you can use the arrow keys for scrolling.

Once you identify your time zone, you can, for example, switch to the Africa/Blantyre time zone using the following command:

timedatectl set-timezone Africa/Blantyre

Getting Command-Line Help

To learn more about timedatectl, issue the following command:

timedatectl help

For more comprehensive coverage of the command, you can check out its man pages by running:

man timedatectl


The Tech Platform

bottom of page