Howto: Linux server change or setup the timezone
Q. My timezone is pointing to wrong timezone. How do I setup or change the timezone?
A. Unix time, or POSIX time, is a system for describing points in time: it is the number of seconds elapsed since midnight UTC on the morning of January 1, 1970, not counting leap seconds.
The definition for time zones can be written in short form as UTC±n (or GMT±n), where n is the offset in hours.
If you are using Fedora Core Linux / Cent OS or RHEL...
Type the redhat-config-date command at the command line to start the time and date properties tool.
# redhat-config-date
OR type setup and select time zone configuration (good for remote text based Linux server)
# setup
Set timezone using /etc/localtime configuration file
Often /etc/localtime is a symlink to the file localtime or to the correct time zone file in the system time zone directory.
Task: Generic procedure to change timezone
Change directory to /etc
# cd /etc
Create a symlink to file localtime:
# ln -sf /usr/share/zoneinfo/EST localtim
OR some distro use /usr/share/zoneinfo/dirname/zonefile format (Red hat and friends)
# ln -sf /usr/share/zoneinfo/EST localtime
OR if you want to set up it to IST (Asia/Calcutta):
# ln -sf /usr/share/zoneinfo/Asia/Calcutta localtime
Please mote that in above example you need to use directory structure i.e. if you want to set the timezone to Calcutta (India) which is located in the Asia directory you will then have to setup using as above.
Use date command to verify that your timezone is changed:
$ date
Output:
Tue Aug 27 14:46:08 EST 2006
Use of environment variable
You can use TZ environment variable to display date and time according to your timezone:
$ export TZ=America/Los_Angeles
$ date
Output:
Thu Aug 27 11:10:08 PST 2006
E-mail this to a friend
Printable version
Related Other Helpful FAQs:
- Linux, UNIX set the time zone on a per user basis
- FreeBSD: Set date time and timezone
- Linux set date and time from command prompt
- Change default Linux / UNIX text editor from VI to Pico
- HP-UX UNIX Configure an NTP Server
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: calcutta, change timezone, Change timezone in Linux, correct time zone, environment variable, leap seconds, localtime, midnight utc, redhat, select time zone, time zones, tz environment, unix time, zone directory




December 20th, 2006 at 8:19 am
Great Info
November 19th, 2007 at 6:51 am
On Ubuntu you can do
tzconfig
to select and set the time zone.
(tzconfig copies the right time zone file from /usr/share/zoneinfo to /etc/localtime and puts the name of the timezone into /etc/timezone)
June 18th, 2008 at 9:52 pm
Counterintuitively, you should not symlink, only ever copy timezone data files. This is because some programs might attempt to alter /etc/localtime. Before you make a change, notice that /etc/localtime is a regular file.