«

Feb 20

Changing TimeZone in Linux System

 

In a linux system timezones are defined under the directory “/usr/share/zoneinfo/”.

[email protected]:~# cd /usr/share/zoneinfo/
[email protected]:/usr/share/zoneinfo# ls
Africa      Asia       Canada   Cuba   EST      Factory  GMT0       Hongkong  Iran         
Japan              localtime  MST7MDT  Pacific   posixrules  ROC        Turkey     UTC           
zone.tab America     Atlantic   CET      EET    EST5EDT  GB       GMT-0      HST       
iso3166.tab  Kwajalein          MET        Navajo   Poland    PRC         ROK        UCT        
WET           Zulu Antarctica  Australia  Chile    Egypt  Etc      GB-Eire  GMT+0      Iceland   
Israel       leap-seconds.list  Mexico     NZ       Portugal  PST8PDT     Singapore  Universal  
W-SU Arctic      Brazil     CST6CDT  Eire   Europe   GMT      Greenwich  Indian    Jamaica      
Libya              MST        NZ-CHAT  posix     right       SystemV    US         zone1970.tab
[email protected]:/usr/share/zoneinfo# 

 

Also, a system’s timezone is defined in the file “/etc/localtime”. This file is generally linked with one of the files in the directory “/usr/share/zoneinfo/”.

[email protected]:~# ls -l /etc/localtime 
lrwxrwxrwx 1 root root 32 Feb 17 03:12 /etc/localtime -> /usr/share/zoneinfo/Asia/Kolkata
[email protected]:~# 

 

So we can change the timezone by simply linking the file “/etc/localtime” with the respective zone file from “/usr/share/zoneinfo/”.

Suppose we want to  change my timezone from IST to UTS, we can do so as :

[email protected]:~# 
[email protected]:~# date
Mon Feb 20 02:49:27 IST 2017
[email protected]:~# ln -sf /usr/share/zoneinfo/UTC /etc/localtime 
[email protected]:~# date
Sun Feb 19 21:19:44 UTC 2017
[email protected]:~# 

If we want to use the timezone¬† based upon region, we can find the desired timezone file in “/usr/share/zoneinfo/”. Like timezone file for IST (Indian Standard Time, i.e., Kolkata) is “/usr/share/zoneinfo/Asia/Kolkata”.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Warning: require_once(): open_basedir restriction in effect. File(/home/admin/web/stats.theserverhouse.com/public_html/owa_php.php) is not within the allowed path(s): (/home/admin/web/linuxjoy.in/public_html:/home/admin/tmp) in /home/admin/web/linuxjoy.in/public_html/index.php on line 20

Warning: require_once(/home/admin/web/stats.theserverhouse.com/public_html/owa_php.php): failed to open stream: Operation not permitted in /home/admin/web/linuxjoy.in/public_html/index.php on line 20

Fatal error: require_once(): Failed opening required '/home/admin/web/stats.theserverhouse.com/public_html/owa_php.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/admin/web/linuxjoy.in/public_html/index.php on line 20