Day.js 中文文档

当前版本 v1.11

更多文档

转换为区域

更改时区并更新偏移量并返回 Day.js 对象实例。

需要配合 Timezone 插件才能工作

dayjs.extend(utc)
dayjs.extend(timezone)

// this example runs in time zone 'Europe/Berlin' (offset +01:00)
dayjs("2013-11-18T11:55:20") // '2013-11-18T11:55:20+01:00'
dayjs("2013-11-18T11:55:20").tz("America/Toronto") // '2013-11-18T05:55:20-05:00'
dayjs("2013-11-18T11:55:20").tz("America/Toronto", true) // '2013-11-18T11:55:20-05:00'

将第二个参数传递为 true 时,仅更新时区(和偏移量),保持本地时间相同。

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