Thursday, October 22, 2009

The TZ Variable








 

 










The TZ Variable



The TZ variable is used by the date command and some Standard C library functions to determine time zone information. The simplest setting for TZ is a time zone name of three or more alphabetic characters followed by a number that specifies the number of hours that must be added to the local time to arrive at Coordinated Universal Time, also known as Greenwich Mean Time. This number can be positive (local time zone is west of 0 longitude) or negative (local time zone is east of 0 longitude). For example, Eastern Standard Time can be specified as





TZ=EST5



The date command calculates the correct time based on this information and also uses the time zone name in its output:





$ TZ=EST5 date

Wed Sep 18 15:24:09 EST 2002

$ TZ=xyz3 date

Wed Sep 18 17:24:28 xyz 2002

$



A second time zone name can follow the number; if this time zone is specified, daylight savings time is assumed to apply (date automatically adjusts the time in this case when daylight saving is in effect) and is assumed to be one hour earlier than standard time. If a number follows the daylight saving time zone name, this value is used to compute the daylight savings time from the Coordinated Universal Time in the same way as the number previously described.



So, the following TZ settings are quivalent:





TZ=EST5EDT

TZ=EST5EDT6



The TZ variable is usually set in either the /etc/profile file or your .profile file. If not set, an implementation-specific default time zone is used, typically Coordinated Universal Time.












     

     


    No comments: