How to set date and time under linux using command line
The date command can be used to set the date and time of a Linux system. It can also be used to print the current date and time.
You can use date command without any arguments to print the current date and time as shown below.
[neo@techpulp ~]# date Sat Nov 8 10:52:28 PST 2008 [neo@techpulp ~]#
Now let us see how to set the date and time using date command. The date command expect the date and time in [MMDDhhmm[[CC]YY][.ss]] format.
Remember you should have super-user privileges to do this. The following example sets the date and time to Dec 31, 2008 10:00.
[root@techpulp ~]# date 123110002008 Wed Dec 31 10:00:00 PST 2008 [root@techpulp ~]# [root@techpulp ~]# date Wed Dec 31 10:00:03 PST 2008 [root@techpulp ~]#


about 2 years ago
There is another command “hwclock” that can display date and time stored in hardware clock (i.e CMOS clock).
[neo@techpulp ~]# hwclock –show
Thu 16 Dec 2010 08:54:38 AM IST -0.966849 seconds
[neo@techpulp ~]#
Generally the date and time set by “date” command automatically sets time in hardware clock as well.
However if you would like to manually synchronize hardware clock to UTC, you can run following command:
[neo@techpulp ~]# hwclock –systohc –utc
about 2 years ago
Alternate way to set accurate time is to use NTP servers available on internet. The command “ntpdate” can be used to synchronize time as shown below:
bash# ntpdate clock2.redhat.com clock.redhat.com
3 Jan 13:20:59 ntpdate[10754]: adjust time server 66.187.233.4 offset -0.024132 sec