时区
Day.js 通过 国际化 API 中的 支持的环境 支持时区。 通过使用原生 API,代码包中不需要包含额外的时区数据字节。
所有时区名称的列表可以在 IANA 数据库.txt 中找到。
对于旧版或不受支持的环境,请使用正确的 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'