Const
The IANA time zone name
Object containing time zone name and short name
Error if the time zone is invalid
const details = TimeZoneUtils.getTimeZoneDetails('America/New_York');
console.log(details);
// Output: { name: 'America/New_York', shortName: 'EDT' }
Gets a list of time zones, optionally filtered and with user's time zone first
Optional
filters: string[]Optional array of time zone names to filter by
Whether to show user's time zone first in the list
Array of time zone objects
// Get all time zones with user's time zone first
const allTimeZones = TimeZoneUtils.getTimeZones();
// Get filtered time zones without user's time zone first
const filteredTimeZones = TimeZoneUtils.getTimeZones(
['America/New_York', 'Europe/London'],
false
);
Gets HTML option elements for time zones
Rest
...filters: string[]Optional array of time zone names to filter by
Array of HTML option strings
// Get options for specific time zones
const options = TimeZoneUtils.getTimeZonesOptions(
'America/New_York',
'Europe/London'
);
// Use in select element
const select = document.createElement('select');
select.innerHTML = options.join('');
Gets details for a specific time zone