How to change the Time on Centos 7,8

Set-Local-Timezone-in-Linux

To change the time on centos, 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 above mentioned 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 Set the Date on Centos 7

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-time 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 “2011-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 on Linux Centos

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 Asia/Kolkata

How to Enable/Disable NTP on Centos

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.

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

SHARE NOW!

About the author

Varun Rastogi

I am a professional digital marketer with over 6+ years of working experience in the digital marketing field. Having worked in SEO, SMM, PPC, and other areas, I know how to bring your brand to the top of the web.

I have worked across many sectors with a special focus on initiating growth and increasing online presence. Always enshrined in the online environment, I still explore even more opportunities for companies in the digital environment.

Get your free quote

top