Javascript allows you to see what time it is in another timezone if you specify the IANA given name of that timezone. For example:
let strTime = new Date().toLocaleString("en-US", {timeZone: "America/Chicago"});
console.log(strTime);
Below you can see that IANA provides multiple names within each general timezone:
America/New_York Eastern (most areas)
America/Detroit Eastern - MI (most areas)
America/Kentucky/Louisville Eastern - KY (Louisville area)
America/Kentucky/Monticello Eastern - KY (Wayne)
America/Indiana/Indianapolis Eastern - IN (most areas)
America/Indiana/Vincennes Eastern - IN (Da, Du, K, Mn)
America/Indiana/Winamac Eastern - IN (Pulaski)
America/Indiana/Marengo Eastern - IN (Crawford)
America/Indiana/Petersburg Eastern - IN (Pike)
America/Indiana/Vevay Eastern - IN (Switzerland)
America/Chicago Central (most areas)
America/Indiana/Tell_City Central - IN (Perry)
America/Indiana/Knox Central - IN (Starke)
America/Menominee Central - MI (Wisconsin border)
America/North_Dakota/Center Central - ND (Oliver)
America/North_Dakota/New_Salem Central - ND (Morton rural)
America/North_Dakota/Beulah Central - ND (Mercer)
America/Denver Mountain (most areas)
America/Boise Mountain - ID (south); OR (east)
America/Phoenix MST - Arizona (except Navajo)
America/Los_Angeles Pacific
America/Anchorage Alaska (most areas)
America/Juneau Alaska - Juneau area
America/Sitka Alaska - Sitka area
America/Metlakatla Alaska - Annette Island
America/Yakutat Alaska - Yakutat
America/Nome Alaska (west)
America/Adak Aleutian Islands
Pacific/Honolulu Hawaii
Why is that necessary?
For example, both America/Detroit and America/New_York are (generally) in the Eastern Time Zone. Why don't these two locations share a single IANA timezone name?
Are there occations of the year where the time in New York is different from that of Detroit?
If not, then why allow more timezone names than the exact number of variances?
There are total of 419 time zones listed.
The tz database is also known as tzdata, the zoneinfo database or IANA time zone database, and occasionally as the Olson database, referring to the founding contributor, Arthur David Olson.
The expansion of transport and communication during the 19th century created a need for a unified time-keeping system, and time zones were introduced. The expansion of transport and communication during the 19th century created a need for a unified time-keeping system.
In 1884 an International Prime Meridian Conference was held in Washington D.C. to standardize time and select the prime meridian. The conference selected the longitude of Greenwich, England as zero degrees longitude and established the 24 time zones based on the prime meridian.
I'll use your example:
For example, both America/Detroit and America/New_York are in the Eastern Time Zone. Why don't these two locations share a single timezone name?
In the TZDB, the Zone
entry for America/New_York
looks like this:
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone America/New_York -4:56:02 - LMT 1883 Nov 18 12:03:58
-5:00 US E%sT 1920
-5:00 NYC E%sT 1942
-5:00 US E%sT 1946
-5:00 NYC E%sT 1967
-5:00 US E%sT
While the Zone
entry for America/Detroit
looks like this:
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone America/Detroit -5:32:11 - LMT 1905
-6:00 - CST 1915 May 15 2:00
-5:00 - EST 1942
-5:00 US E%sT 1946
-5:00 Detroit E%sT 1973
-5:00 US E%sT 1975
-5:00 - EST 1975 Apr 27 2:00
-5:00 US E%sT
To fully decipher this, one also needs the Rule
entries for US
, NYC
, and Detroit
(which I won't copy/paste here, but you can follow the links).
As you can see, Detroit has had variations from New York, the last of which was in 1975 when Detroit started daylight saving time slightly later than most of the Eastern time zone (Apr 27 shown here vs Feb 23rd given by Rule US).
Since then however, they have been the same. The TZDB rules require a unique zone for areas that have agreed since 1970, and these areas have deviations in 1973 and 1975, thus they require unique zone identifiers.
One can see this difference in JavaScript like so:
var d = new Date("1975-03-01T00:00:00.000Z"); // Midnight UTC on March 1st
d.toLocaleString("en-US", {timeZone: "America/New_York"}) //=> "2/28/1975, 8:00:00 PM"
d.toLocaleString("en-US", {timeZone: "America/Detroit"}) //=> "2/28/1975, 7:00:00 PM"
Of course, if in your application, you never deal with dates going back that far, then you can just use America/New_York
to represent the US Eastern time zone, and omit America/Detroit
(and a few others) - but this is entirely your decision to make.
You may also be interested in reading the Theory file with in the tzdb itself, which explains the concepts and principles of the time zone database in a lot more detail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With