How to Set or Change Date and Time on CentOS 7

CentOS 7 offers three command line tools that can be used to configure and display information about the system date and time:

  • The "timedatectl" utility, which is part of systemd.
  • The traditional "date" command.
  • The "hwclock" utility for accessing the hardware clock.


Display Date and Time

To view the current date and time of the system, run the below command.


Below output shows that System time zone is set to America/New_York.


[root@linuxyogi ~]# timedatectl
      Local time: Wed 2021-04-28 10:15:52 EDT
  Universal time: Wed 2021-04-28 14:15:52 UTC
        RTC time: Wed 2021-04-28 14:15:50
       Time zone: America/New_York (EDT, -0400)
     NTP enabled: n/a
NTP synchronized: no
RTC in local TZ: no
      DST active: yes
Last DST change: DST began at
                  Sun 2021-03-14 01:59:59 EST
                  Sun 2021-03-14 03:00:00 EDT
Next DST change: DST ends (the clock jumps one hour backwards) at
                  Sun 2021-11-07 01:59:59 EDT
                  Sun 2021-11-07 01:00:00 EST

Display the list of all available time zones

To view all the available time zones, run the below command.

timedatectl list-timezones

Below output shows the time zones list.


[root@linuxyogi ~]# timedatectl list-timezones

Change the current date
  1. Date can be changed by using the below syntax.

# timedatectl set-time [YYYY-MM-DD]

timedatectl set-time 2021-05-01

Change the current time

1. Time can changed by using the below syntax. It will set the time in 24-hour format.

# timedatectl set-time [HH:MM:SS]

timedatectl set-time 17:23:10

Change the time-zone
  1. Set the time-zone by using the below command.

timedatectl set-timezone 'Asia/Kolkata'

Verify the changes.


[root@linuxyogi ~]# timedatectl
      Local time: Sat 2021-05-01 17:50:02 IST
  Universal time: Sat 2021-05-01 12:20:02 UTC
        RTC time: Sat 2021-05-01 12:20:03
       Time zone: Asia/Kolkata (IST, +0530)
     NTP enabled: n/a
NTP synchronized: no
RTC in local TZ: no
      DST active: n/a

Synchronize the System Clock with a Remote NTP Server

Automatic system clock synchronizing can be done by using NTP (Network Time Protocol) which is an internet protocol. The timedatectl utility enables us to automatically sync the system clock with remote servers using NTP.

*note: NTP package need to be installed on the system to enable auto time synchronization with NTP servers. In case not installed, use the below command.

yum install ntp -y

Use the below command to enable this feature.

timedatectl set-ntp true

Use the below command to disable this feature.

timedatectl set-ntp false