While using the Intl.DateTimeFormat
, I noticed that the timezone short names are not set when using a locale which does not have the specified timezone, for example en-US locale does not contain the Australia/Sydney
timezone information.
Is there a way to display AEST
while keeping the en-US
locale? Otherwise we'll have to map IANA timezones to locales, which seems overkill.
var date = new Date();
var options = {
hour: 'numeric', minute: 'numeric', second: 'numeric',
timeZone: 'Australia/Sydney',
timeZoneName: 'short'
};
// displays 12:14:27 am AEST
console.log(new Intl.DateTimeFormat('en-AU', options).format(date));
// 12:14:27 AM GMT+10
console.log(new Intl.DateTimeFormat('en-US', options).format(date));