Time Zone
Day.js supports time zone via the Internationalization API in supported environments. By using the native API, no extra bytes of timezone data need to be included in code bundle.
The list of all time zone names can be found in the IANA database.
For legacy or unsupported environments, please use a proper polyfill.
This requires the
Timezone
plugin to work
dayjs.extend(utc)
dayjs.extend(timezone)
// current time zone is 'Europe/Berlin' (offset +01:00)
// Parsing
dayjs.tz("2013-11-18 11:55:20", "America/Toronto") // '2013-11-18T11:55:20-05:00'
// Converting (from time zone 'Europe/Berlin'!)
dayjs("2013-11-18 11:55:20").tz("America/Toronto") // '2013-11-18T05:55:20-05:00'