CentOS 7

How To Change Time/Date In Linux From Command Prompt

Share on LinkedIn

These commands work with CentOS 6.5. The commands for CentOS 7 are similar and you should be able to figure them out if you start with these commands.

Only change time not date:

To only set the time use like this:

# date -s hh:mm:ss

Update Hardware clock:

To sync the hardware clock to the current system clock:

# hwclock –systohc
# hwclock –systohc –utc
***** use the second option if you use UTC.

Set Hardware clock manually:

To know the current time of the hardware clock:

# hwclock –show
Tue Nov  4 22:13:40 2003  -0.684660 seconds

To set the hw clock manually:

# hwclock –set –date=”09/21/2005 14:23:23″


We run into power issues from time to time and our servers have been known to lose their time. The hardware time may not have been changed and the system often synchronizes off of the hardware clock, especially following a power cycle.

Below are the steps I performed to 1. change the system clock to the correct time and then 2. synchronize the hardware clock up to the system clock.

[root@ ~]# date -s 16:30:00
Mon Jan 26 16:30:00 CST 2015
[root@ ~]# date
Mon Jan 26 16:30:05 CST 2015
[root@ ~]# hwclock –show
Mon 26 Jan 2015 03:09:58 PM CST -0.188457 seconds
[root@ ~]# hwclock –systohc –utc
[root@ ~]# hwclock –show
Mon 26 Jan 2015 04:35:40 PM CST -0.616988 seconds