We are currently exploring showing timestamps with time zone to our users and decided to go with the Intl.DateTimeFormat
option timeZoneName: "shortOffset"
but we now noticed that the value is different between the languages.
When I run this snippet in chrome printing the timezone in different languages:
["it-IT", "da-DK", "de-DE", "en-GB", "es-ES", "pl-PL", "fr-FR", "sv-SE", "nl-NL", "nb-NO", "el-GR", "fi-FI", "pt-PT", "cs-CZ", ].forEach((l) => {
const tz = Intl.DateTimeFormat(l, {
timeZone: "Asia/Kolkata",
timeZoneName: "shortOffset",
})
.formatToParts(new Date())
.find((p) => p.type === "timeZoneName").value;
console.log(l, tz);
});
I get this result:
language | timezone |
---|---|
it-IT | GMT+5:30 |
da-DK | GMT+5.30 |
de-DE | GMT+5:30 |
en-GB | GMT+5:30 |
es-ES | GMT+5:30 |
pl-PL | GMT+5:30 |
fr-FR | UTC+5:30 |
sv-SE | GMT+5:30 |
nl-NL | GMT+5:30 |
nb-NO | GMT+5:30 |
el-GR | GMT+5:30 |
fi-FI | UTC+5.30 |
pt-PT | GMT+5:30 |
cs-CZ | GMT+5:30 |
so for some reason french and finnish are using the label UTC and all the other tested languages are using GMT.
I would really like to know what the reason behind this is. Is there any documentation or database where I can find the configuration of the different languages for Intl.DateTimeFormat
?
A few things:
Intl
API responses originates from Unicode CLDR (not IANA).gmtFormat
internally. For example, you can see here in French it's specified as <gmtFormat>UTC{0}</gmtFormat>
where here in English it's specified as <gmtFormat>GMT{0}</gmtFormat>
.GMT Format
in this chart), or uses it at all (Chinese, Japanese, etc.), so replacements might not always fit every language.