Hamsa K
Editor
5 min read | 3 years ago

How to Change TimeZone in Centos 7

change timezone in centos 7

First we need to login into the server with root or any other user with sudo previliges. Then check with timedatectl command like  below

[root@localhost ~]# timedatectl
      Local time: Mon 2020-03-23 16:46:50 IST
  Universal time: Mon 2020-03-23 11:16:50 UTC
        RTC time: Mon 2020-03-23 11:16:50
       Time zone: Asia/Kolkata (IST, +0530)
     NTP enabled: n/a
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

you can use the following command to list all the available time zones.

[root@localhost ~]# timedatectl list-timezones

Now you can change timezone to desired one.

timedatectl set-timezone your_desired_zone

suppose if you want to change to London timezone then

[root@localhost ~]# timedatectl set-timezone Europe/London

Also Read -> How to Install Nodejs on Centos 7

Now check date and time with date command

[root@localhost ~]# date
Mon Mar 23 11:27:39 GMT 2020

If your server doesn’t work timedatectl command, then follow belowone.you  need to take backup of localtime first and then delete localtime and create symlink for that file.

[root@localhost ~]# cp -rv /etc/localtime /etc/localtime-org

now delete localtime and create symlink

[root@localhost ~]# rm -rf /etc/localtime
[root@localhost ~]# ln -s /usr/share/zoneinfo/Europe/London /etc/localtime

now check timezone once.

set date and time

you can set date and time using following commands.

To change the current time, use the following syntax. Enter the hour by using a 24-hour clock.

[root@localhost ~]# timedatectl set-time 16:10:30

To change date use below command

To set date, you can use set-time along the format of date in YY:MM:DD

[root@localhost ~]# timedatectl set-time 2020-03-24

To set both date and time, then use below command

[root@localhost ~]# timedatectl set-time '2020-03-25 16:12:42'

To configure your system to maintain the clock in the local time, use below

[root@localhost ~]# timedatectl set-local-rtc yes

To configure your system to use 'UTC",then use following command.

[root@localhost ~]# timedatectl set-local-rtc no

Also Read -> How to Install Webmin on Centos 7

Synchronizing systemclock with Remote NTP servers

NTP is used to synchronize system clock between computers. timedatectl utility enables you to automatically sync your Linux system clock with remote servers using NTP.

Note: you must have NTP installed on the system to enable automatic time synchronization with NTP servers.

[root@localhost ~]# yum install ntp
[root@localhost ~]# timedatectl set-ntp yes

To disable NTP time synchronization,use following command

[root@localhost ~]# timedatectl set-ntp false

Also Read -> How to Install Mariadb on Centos 8



Warning! This site uses cookies
By continuing to browse the site, you are agreeing to our use of cookies. Read our terms and privacy policy