转换为区域
更改时区并更新偏移量并返回 Day.js 对象实例。
¥Change the time zone and update the offset and return a Day.js object instance.
This requires the
Timezone
plugin to work
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 时,仅更新时区(和偏移量),保持本地时间相同。
¥On passing a second parameter as true, only the timezone (and offset) is updated, keeping the local time same.