date to display the EDT time
I want to check the time
Eastern Daylight Time Time zone in Washington, DC, USA (GMT-4) Thursday, May 9, 2019, 8:11 PM
However,
$ TZ="EDT" date
Fri May 10 00:12:25 EDT 2019"EST" works properly
$ TZ="EST" date
Thu May 9 19:13:11 EST 2019What's the problem?
2 Answers
date command doesn't know "EDT" timezone. If a timezone which isn't supported is passed in TZ the output will indeed show with entered time zone but time shown will be UTC.
Supported time zones are listed in /usr/share/zoneinfo/. As of now time zones that can be used as a value for "TZ" are:
Africa Cuba GMT0 Japan Pacific Turkey
America EET GMT-0 Kwajalein Poland UCT
Antarctica Egypt GMT+0 leap-seconds.list Portugal Universal
Arctic Eire Greenwich Libya posix US
Asia EST Hongkong localtime posixrules UTC
Atlantic EST5EDT HST MET PRC WET
Australia Etc Iceland Mexico PST8PDT W-SU
Brazil Europe Indian MST right zone1970.tab
Canada Factory Iran MST7MDT ROC zone.tab
CET GB iso3166.tab Navajo ROK Zulu
Chile GB-Eire Israel NZ Singapore
CST6CDT GMT Jamaica NZ-CHAT SystemVThe time zone for EDT is "EST5EDT". The output of TZ="EST5EDT" date as of 10 May 2019 02:11:26 UTC:
Thu May 9 22:11:26 EDT 2019Or use city's name where EDT is used. Examples: America/Kentucky/Louisville, America/Kentucky/Monticello, America/New_York, Canada/Eastern, etc.
Why EDT is EST5EDT?
In short, it is a standard. Time zones are written like Timezone-Offset. Here - is minus or it can be said for time zones which are ahead of UTC are written like Timezone-Offset and for time zones that are behind UTC, it is written as TimezoneOffset. If the time zone has a pretty name like Eastern Standard Time, it can be written as EST or EST5. Both will produce same results.
Now, Daylight Saving Time (DST) isn't observed everywhere (for example, India). For time zones where it is observed, time zones are written as Timezone-OffsetTimezoneDST, example: EET-2EETDST (Cyprus) but if DST has a fancy name like BST (British Summer Time), it is written as Timezone-OffsetFancy_name, i.e. GMT0BST. Similary, EDT is EST5EDT. On this Oracle document you can see all standardized time zones.
EDT is ambiguous when considered internationally. You can get the time you are seeking by doing
$ TZ="America/New_York" date
Thu May 9 22:11:16 EDT 2019