轉換為時區
變更時區並更新偏移量,並傳回一個 Day.js 物件實例。
這需要 時區
外掛才能運作
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,則只會更新時區(和偏移量),而當地時間保持不變。