Send in your Unix questions today! |
See additional Unix tips and tricks
In last week's column, I encouraged anyone who hasn't already patched their OSes for the imminent daylight savings time changes. This week, we look at a command for displaying timezone data and verifying the date on which the switch to DST will be made.
The command is zdump. In its simplest form, zdump displays the current time for whatever timezone is requested. For example, in the commands below, you can see that EST is five hours behind UTC (Universal Time). The output of the zdump command is almost identical to that of the date command, but includes the timezone at the start of the line.
> zdump EST
EST Sat Feb 3 14:28:00 2007 EST
> zdump UTC
UTC Sat Feb 3 19:28:00 2007 UMT
> date
Sat Feb 3 14:28:00 EST 2007
|
You can also use the zdump command with timezone files for various regions of the world:
> zdump US/Eastern
US/Eastern Sat Feb 3 14:39:33 2007 EST
> zdump /usr/share/lib/zoneinfo/Australia/North
/usr/share/lib/zoneinfo/Australia/North Sun Feb 4 05:09:33 2007 CST
> zdump Singapore
Singapore Sun Feb 4 03:39:33 2007 SGT\
If you add a -v (verbose) argument to your zdump command, the command will display all of the information in the otherwise unreadable zone file. For many zones, this will be far more information than you want to see. The output below shows only bottom lines from the zdump output for US/Eastern. Notice how the data stops in 2038:
US/Eastern Sun Nov 2 05:59:59 2036 UTC = Sun Nov 2 01:59:59 2036 EDT isdst=1
US/Eastern Sun Nov 2 06:00:00 2036 UTC = Sun Nov 2 01:00:00 2036 EST isdst=0
US/Eastern Sun Mar 8 06:59:59 2037 UTC = Sun Mar 8 01:59:59 2037 EST isdst=0
US/Eastern Sun Mar 8 07:00:00 2037 UTC = Sun Mar 8 03:00:00 2037 EDT isdst=1
US/Eastern Sun Nov 1 05:59:59 2037 UTC = Sun Nov 1 01:59:59 2037 EDT isdst=1
US/Eastern Sun Nov 1 06:00:00 2037 UTC = Sun Nov 1 01:00:00 2037 EST isdst=0
US/Eastern Tue Jan 19 03:14:07 2038 UTC = Mon Jan 18 22:14:07 2038 EST isdst=0
US/Eastern Mon Jan 18 03:14:07 2038 UTC = Sun Jan 17 22:14:07 2038 EST isdst=0
|
This output also tells you that daylight savings time in the US/Eastern timezone in 2037 will start on March 8th. The isdst=0 (read "is dst") and isdst=1 indicate the transition from standard time to daylight savings.
To examine daylight savings times transitions for New York City (this is the same as US/Eastern), you can use the zdump command and grep on the year:
# zdump -v America/New_York | grep 2007
America/New_York Fri Jan 26 21:33:07 2007 UTC = Fri Jan 26 16:33:07 2007 EST isdst=0
America/New_York Sun Mar 11 06:59:59 2007 UTC = Sun Mar 11 01:59:59 2007 EST isdst=0
America/New_York Sun Mar 11 07:00:00 2007 UTC = Sun Mar 11 03:00:00 2007 EDT isdst=1
America/New_York Sun Nov 4 05:59:59 2007 UTC = Sun Nov 4 01:59:59 2007 EDT isdst=1
America/New_York Sun Nov 4 06:00:00 2007 UTC = Sun Nov 4 01:00:00 2007 EST isdst=0
|
This output shows that daylight savings starts on March 11th and ends on November 4th.
Don't try your own city or region unless you find it in the /usr/share/lib/zoneinfo/America directory or the /usr/share/lib/zoneinfo/ directory.
If you're interested in determining the day that the change will take place next year or 10 years from now, you can try a command similar to those below:
# zdump -v Canada/Eastern | grep 2008
Canada/Eastern Sun Mar 9 06:59:59 2008 UTC = Sun Mar 9 01:59:59 2008 EST isdst=0
Canada/Eastern Sun Mar 9 07:00:00 2008 UTC = Sun Mar 9 03:00:00 2008 EDT isdst=1
Canada/Eastern Sun Nov 2 05:59:59 2008 UTC = Sun Nov 2 01:59:59 2008 EDT isdst=1
Canada/Eastern Sun Nov 2 06:00:00 2008 UTC = Sun Nov 2 01:00:00 2008 EST isdst=0
# zdump -v Europe/Nicosia | grep 2018
Europe/Nicosia Sun Mar 25 00:59:59 2018 UTC = Sun Mar 25 02:59:59 2018 EET isdst=0
Europe/Nicosia Sun Mar 25 01:00:00 2018 UTC = Sun Mar 25 04:00:00 2018 EEST isdst=1
Europe/Nicosia Sun Oct 28 00:59:59 2018 UTC = Sun Oct 28 03:59:59 2018 EEST isdst=1
Europe/Nicosia Sun Oct 28 01:00:00 2018 UTC = Sun Oct 28 03:00:00 2018 EET isdst=0
|
Sandra Henry-Stocker has been administering Unix systems
for more than 18 years. She describes herself as "USL"
(Unix as a second language) but remembers enough English
to write books and buy groceries. She
currently works for TeleCommunication Systems, a wireless
communications company, in Annapolis, Maryland, where no
one else necessarily shares any of her opinions. She lives
with her second family on a small farm on Maryland's
Eastern Shore. Send comments and suggestions to bugfarm@gmail.com.
|