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.
Generic procedure to change timezone
Change directory to /etc
# cd /etc
Create a symlink to file localtime e.g.
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
Please do check with date command:
$ date
Output:
Mon Oct 8 16:39:56 IST 2012
Use of environment variable
You can use TZ environment variable to display date and time according to your or other timezones:
$ export TZ=Asia/Calcutta
$ date
Output:
Mon Oct 8 16:39:56 IST 2012
Here is the small script to check TIME from US-Chicago,Shanghai and India.
#!/bin/bash
echo -ne "India\t\t\c \t"
export TZ=Asia/Calcutta
date
echo -ne "Shanghai\t\c \t"
export TZ=Asia/Shanghai
date
echo -ne "US-Chicago\t\c \t"
export TZ=America/Chicago
date
No comments:
Post a Comment