Tzdata is a collection of the worlds time zone information and can be used to set the time for individual users on a Linux system.
To use it first download the tzdata package from the repo.
$ sudo yum -y install tzdata
$ tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
1) Africa
2) Americas
3) Antarctica
4) Arctic Ocean
5) Asia
6) Atlantic Ocean
7) Australia
8) Europe
9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#?
Select a value and press the return key to proceed.
You will now be asked a country to select from the list provided.
Please select a country.
1) Aaland Islands 18) Greece 35) Norway
2) Albania 19) Guernsey 36) Poland
3) Andorra 20) Hungary 37) Portugal
4) Austria 21) Ireland 38) Romania
5) Belarus 22) Isle of Man 39) Russia
6) Belgium 23) Italy 40) San Marino
7) Bosnia & Herzegovina 24) Jersey 41) Serbia
8) Britain (UK) 25) Latvia 42) Slovakia
9) Bulgaria 26) Liechtenstein 43) Slovenia
10) Croatia 27) Lithuania 44) Spain
11) Czech Republic 28) Luxembourg 45) Sweden
12) Denmark 29) Macedonia 46) Switzerland
13) Estonia 30) Malta 47) Turkey
14) Finland 31) Moldova 48) Ukraine
15) France 32) Monaco 49) Vatican City
16) Germany 33) Montenegro
17) Gibraltar 34) Netherlands
Select and confirm the selection with 1 for Yes.
This completes the setup but to make it permanent you should add the following line to your ~/.bashrc file.
TZ='Europe/London'; export TZ
Then log out and back in again.
The user can now log in and run the date command
$ date
Fri Jul 19 14:56:53 BST 20
Other commands
Set the date to 19th July 2013
Syntax is date --set="YYYYMMDD"
$ date --set="20130719"
Fri Jul 19 00:00:00 BST 2013
Set the time to 14.10
Syntax is date +%T -s "HH:MM:SS"
$ date +%T -s "14:10:34"
14:10:34
See also OpenNTPD
Labels: Centos 6, RHEL, Tzdata time zone utilty