Day.js 中文文档

当前版本 v1.11

更多文档

时区

Day.js 在 支持的环境中 通过 国际化 API 支持时区。通过使用原生 API,代码包中无需包含额外的时区数据字节。

对于旧版或不受支持的环境,请使用正确的 polyfill

需要配合 Timezone 插件才能工作

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'

Day.js 中文文档 - 粤ICP备14034220号-1