TZ Variable (The GNU C Library) (original) (raw)
22.5.6 Specifying the Time Zone with TZ ¶
In POSIX systems, a user can specify the time zone by means of theTZ environment variable. For information about how to set environment variables, see Environment Variables. The functions for accessing the time zone are declared in time.h.
You should not normally need to set TZ. If the system is configured properly, the default time zone will be correct. You might set TZ if you are using a computer over a network from a different time zone, and would like times reported to you in the time zone local to you, rather than what is local to the computer.
The value of TZ can be in one of the following formats:
- The geographical format specifies a location that stands for the past and future time zones observed in that location. See Geographical Format for TZ. Here are some examples:
Asia/Tokyo
America/New_York
/usr/share/zoneinfo/America/Nuuk - The proleptic format represents a time zone that has always been and always will be the same offset from UTC, optionally with a simple daylight saving scheme that has always been (and always will be) used every year. See Proleptic Format for TZ. Here are some examples:
JST-9
EST+5EDT,M3.2.0/2,M11.1.0/2
<-02>+2<-01>,M3.5.0/-1,M10.5.0/0 - The colon format begins with ‘:’. Here is an example.
Each operating system can interpret this format differently; in the GNU C Library, the ‘:’ is ignored and charactersare treated as if they specified the geographical or proleptic format. - As an extension to POSIX, when the value of
TZis the empty string, the GNU C Library uses UTC.
If the TZ environment variable does not have a value, the implementation chooses a time zone by default. In the GNU C Library, the default time zone is like the specification ‘TZ=/etc/localtime’ (or ‘TZ=/usr/local/etc/localtime’, depending on how the GNU C Library was configured; see Installing the GNU C Library). Other C libraries use their own rule for choosing the default time zone, so there is little we can say about them.