解决方案
假设我们需要将韩国时间 Asia/Seoul
2022-07-05 23:42:48 转换为美国用户 America/New_York
显示的时间.
1 2 3 4 5 6 7 8
| import dayjs from 'dayjs' import utc from 'dayjs/plugin/utc'; import timezone from 'dayjs/plugin/timezone'
let b = dayjs.tz("2022-07-05 23:42:48", "Asia/Seoul") const timestamp2 = b.utc().unix() console.log(dayjs.unix(timestamp2).tz('America/New_York').format('YYYY-MM-DD HH:mm:ss'),'dayjs')
|