PL EN

Intl API lista timezone

Metody do listowania obsługiwanych stref czasowych oraz pobierania informacji o aktualnej strefie użytkownika.

const timeZones = Intl.supportedValuesOf('timeZone')
const currentTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
const dateTimeFormatOptions = Intl.DateTimeFormat().resolvedOptions()

Przykład użycia:

console.log(timeZones)
// ['Africa/Abidjan', 'Africa/Accra', 'Africa/Addis_Ababa', ...]
// i wiele wiele więcej..

console.log(currentTimeZone)
// 'Europe/Warsaw'

console.log(dateTimeFormatOptions)
/*
{
    "locale": "pl",
    "calendar": "gregory",
    "numberingSystem": "latn",
    "timeZone": "Europe/Warsaw",
    "year": "numeric",
    "month": "2-digit",
    "day": "numeric"
}
*/

Powrót do szortów