Some times you might be able to execute very complex commands and write pages of shell scripts and yet find your-self in a clueless situation, like the seemingly mundane task of setting the data/time in your Linux box from the command line. Here are a couple of ways that might help –

1. Using /etc/localtime and /usr/share/zoneinfo

Create a link to the file in /usr/share/zoneinfo which contains the time zone you want to set your clock to.

ln -s /usr/share/zoneinfo/America/New_York /etc/localtime

2. Edit /etc/sysconfig/clock

vi /etc/sysconfig/clock

-set the “ZONE” variable to your region – like “US/Central”

3.  Export command

Export TZ=America/New_York

4. Set the date using date command –

Example

date -s '2010-07-09 13:19:55'

5. Hardware clock

hwclock --set --date='07/09/2010 13:19:55'