Your computer has both a hardware clock and a software clock. The hardware clock is rudimentary, keeping track only of current values for the year, month, day, hour, minute and second, much like an old-school digital alarm clock.
The system clock is much more advanced, having knowledge not only of the current time but also the current timezone and whether it’s Daylight Savings Time or not. The system clock calculates these values from the hardware clock based on adjustments that you set. You can easily make these adjustments by means of a utility called timedatectl which is included with Systemd.
As mentioned above, you’ll use timedatectl to set the time and date on CentOS 7. This utility is distributed as part of the systemd system and service manager which is included in the standard CentOS distribution. The timedatectl command has the following features:
• Review the current date and time
• Change the date and time
• Set up the system time zone
• Enable an automatic synchronization of the system clock with a remote server via NTP, the Network Time Protocol
Set up a new time zone on CentOS 7 using timedatectl
With this command, you can see your current timezone settings using timedatectl:
Local time: Fri 2016-06-02 04:21:01 EDT
Universal time: Fri 2016-06-02 08:21:01 UTC
RTC time: n/a
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 2016-03-13 01:59:59 EST
Sun 2016-03-13 03:00:00 EDT
Next DST change: DST ends (the clock jumps one hour backwards) at
Sun 2016-11-06 01:59:59 EDT
Sun 2016-11-06 01:00:00 EST
You can also list all timezone options that are available to you using the timedatectl list-timezones command. The output for this command is very large. To obtain more specific results, you can use grep to filter for certain strings. For example, if you like a list of the timezones located in the Americas, you can use this command below:
timedatectl list-timezones | grep America
Set up your timezone with whichever timezone you wish. In our example, we’ll choose “America/New_York”:
timedatectl set-timezone America/New_York
In addition you may configure a specific date and time, using this following syntax:
timedatectl set-time "YYYY-MM-DD HH:MM:SS"
We suggest that you set your server date and time using an universal clock server using a Network Time Protocol.
It’s important to ensure that your system clock is set accurately, as inaccurate dates, times and/or timezones can wreak havoc with files and program operation. Luckily, if you’re running Systemd, timedatectl is an easy way to make adjustments as necessary. If this guide was helpful to you, kindly share it with others who may also be interested.