How to Set Date, Time and Timezone in RHEL 8

When it comes to Date and Time configurations, all operating systems are familiar with two types of clocks; real-time clock (RTC) and system clock.

RTC/hardware clock is tied to the computer’s integrated circuit, which remains active even when the computer is not running. On the other hand, the operability of the system/software clock depends on the system kernel. The system clock takes the hardware clock’s value as its initial value.

[ You might also like: How to Check and Repair a File System in RHEL Linux ]

When an operating system is brought to life for the first time, the software clock value becomes independent of the hardware clock value making it possible for a user to set this value to a new one based on their preferred Coordinated Universal Time (UTC) or local time. However, most operating systems like RHEL 8 recommend users to go with UTC.

Set Date and Time in RHEL 8

There are several Date and Time configuration approaches supported by RHEL 8. All these system Date and Time configuration approaches are accessible from the command line.

For this article guide, we are going to look at the timedatectl command.

timedatectl Command

The systemd system and service manager are responsible for this Date and Time command-line utility. This command is used to alter the system/software clock values.

The timedatectl command achieves the following functionalities:

  • Synchronizing the system clock of a local server/machine with that of a remote server/machine.
  • Editing the currently set timezone.
  • Configuring the current date and time.

Check Date and Time in RHEL

To display the current date and time setting on your RHEL 8 system, execute the following command on your terminal:

$ timedatectl
Check Time in RHEL
Check Time in RHEL

The command outputs the Local time, Universal time, RTC time, and associated Time zone.

Change Time in RHEL

Before you can change the date and time settings on your RHEL system, you need to temporarily disable the NTP service.

$ sudo timedatectl set-ntp no

To change the current local time, we must adhere to the following syntax rule:

$ sudo timedatectl set-time HH:MM:SS

Where HH is for hours, MM for minutes, and SS for seconds.

An example implementation is as follows:

$ sudo timedatectl set-time 18:05:00

Confirm that the set time:

$ timedatectl
Confirm Time in RHEL
Confirm Time in RHEL

As you can see, the Universal time and the RTC time were also automatically adjusted.

Change Date in RHEL

To change the current date, adhere to the following command syntax:

$ sudo timedatectl set-time YYYY-MM-DD

Where YYYY is for a year, MM for a month, and DD for a day.

A practical implementation of the above command is as follows:

$ sudo timedatectl set-time 2021-11-17
Confirm Date in RHEL
Confirm Date in RHEL

While changing the current date, the current time might be altered. To avoid such inconvenience, first, change the date and then the local time.

Change Timezone in RHEL

To change/edit the Time Zone you are under, adhere to the following command syntax:

$ sudo timedatectl set-timezone your_preferred_time_zone

However, it is advisable to get a sneak peek of available and supported timezones under RHEL 8 using the following command.

$ timedatectl list-timezones
List Timezone in RHEL
List Timezone in RHEL

From here, you can implement the timezone of your choice:

$ sudo timedatectl set-timezone America/Aruba 

Confirm that the timezone was successfully added.

$ timedatectl
Check Timezone in RHEL
Check Timezone in RHEL

These date and time configuration changes you have made on your local rhel system can also be automatically synchronized with remote machines and servers you might be using.

Since remote servers and machines understand the NTP protocol, you only need to enable it for your remote servers/machines to be in-sync with your system/software clock.

$ sudo timedatectl set-ntp yes

The timedatectl command is flexible enough to meet all your RHEL 8 date and time configuration needs. It is easy to memorize and implement making your date and time associated system tasks manageable.

2 thoughts on “How to Set Date, Time and Timezone in RHEL 8”

  1. In the section on time zones, there is a typo. Instead of `sudo datetimectl set-timezone your_preferred_time_zone` the command should be `sudo timedatectl set-timezone your_preferred_time_zone`.


Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.