Change Time and Date on RHEL/CentOS and Fedora
This post shows how to set the time and date in the command line on RHEL/CentOS 8 and Fedora 30. The correct system time is essential for systems and creates the prerequisite for the proper functioning of many service. The command line tool timedatectl
use to check and modify time setting.
Run the query using timedatectl
without additional arguments:
1 2 3 4 5 6 7 8 9 |
$ timedatectl Local time: Wed 2021-02-17 17:04:29 GMT Universal time: Wed 2021-02-17 17:04:29 UTC RTC time: Wed 2021-02-17 16:57:58 Time zone: Europe/London (GMT, +0000) System clock synchronized: yes NTP service: active RTC in local TZ: no |
To set-time switch along with the format of time in HH:MM:SS (Hour, Minute, and Seconds):
1 2 |
$ timedatectl set-time 14:09:05 |
To set-time switch along with the format of date in YY:MM:DD (Year, Month, Day):
1 2 |
$ timedatectl set-time 2021-02-18 |
To set both date and time:
1 2 |
$ timedatectl "2021-02-18 14:09:05" |
Find out if your hardware clock is set to local timezone:
1 2 |
$ timedatectl | grep local |
Set your hardware clock to local timezone:
1 2 |
$ timedatectl set-local-rtc 1 |