Skip to content

Use locale for DateTimeFormat timezone names #2933

@s-summers

Description

@s-summers

Currently the DateTimeFormat that is created uses en-US as the locale. However this is not sufficent to include the desired timezone name.

const getDateTimeFormat = (timezone, options = {}) => {
const timeZoneName = options.timeZoneName || 'short'
const key = `${timezone}|${timeZoneName}`
let dtf = dtfCache[key]
if (!dtf) {
dtf = new Intl.DateTimeFormat('en-US', {
hour12: false,
timeZone: timezone,
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
timeZoneName
})
dtfCache[key] = dtf
}
return dtf
}

For example:

getDateTimeFormat('Australia/Sydney').format(new Date())
// '09/15/2025, 09:39:52 GMT+10'

whereas if it was switched to en-AU we get the following

getDateTimeFormat('Australia/Sydney').format(new Date())
// '15/09/2025, 09:39:52 AEST'

Notice that with en-US the timezone is GMT+10 but with en-AU it is AEST.

I would like to request a change such that the dayjs.locale set by imports like import 'dayjs/locale/en-au' is also used when constructing the DateTimeFormat.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions