How To: Set the Date and Time in Linux (from the console)
You may need to change or set the Date and Time in Linux from the console (also know as the command prompt by Windows users). The best option is to sync with an NTP but this short guide will show you how to set the Date and Time in Linux manually. This guide uses CentOS Linux but it should apply to any Linux distribution.
Set the Date and Time in Linux
As root use the date command to set the date and time in CentOS:
Replace MMDDhhmmYYYY with the appropriate values. The values are:
MM – Two digit month number
DD – Two digit date
hh – Two digit 24 hour system hour
mm – Two digit minute
YYYY – Four digit year code
Example:
This will set the date to: Sat Jun 12 11:23:00 EDT 2010
Setting Only the Time in Linux
hh – Two digit 24 hour system hour
mm – Two digit minute
Examples:
$ date --set 18:00 ;sets the time to 6:00PM
Setting Only the Date in Linux
Examples:
This will set the date to June 12th, 2010.
Social Links
Thank you for taking the time to read this post. We hope you've enjoyed the
content here. Please feel free to use the links below to share this post with others.