How to Change Date and Time Linux on RHEL 6/7 and CentOS 6/7

This post assumed that your Red Hat Enterprise Linux 6 (RHEL 6) does not have Date/Time Properties installed. In order to change the date and

In order to change date and time you will have to perform the changes from the command line. Note that in order to perform actions described in this post, you have to be logged in as a root:

1. Change the current date with the following form :

# date +%D -s YYYY-MM-DD

Linux Date Format : YYYY with a four-digit year, MM with a two-digit month, and DD with a two-digit day of the month.
Example :

# date +%D -s 2012-05-30
05/30/12

2. Change the current time with the following form :

# date +%T -s HH:MM:SS

If your system clock is set to use UTC (Coordinated Universal Time), add the following option :

# date +%T -s HH:MM:SS -u

Note : HH stands for an hour, MM is a minute, and SS is a second

# date +%T -s 22:30:00
22:30:00

or

[root@rhel6 ~]# date +%T -s 22:30:00 -u
22:30:00

3. How to Display current date and time :

[root@rhel6 ~]# date
Wed May 30 22:30:04 MYT 2012

Reference

  • https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/chap-Configuring_the_Date_and_Time.html
  • https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sect-Date_and_Time_Configuration-Command_Line_Configuration.htmlhtml