You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importdayjsfrom'dayjs';importtimezonefrom'dayjs/plugin/timezone';importutcfrom'dayjs/plugin/utc';dayjs.extend(utc)dayjs.extend(timezone)constdatetime="2022-10-02";console.log(dayjs.tz.guess())constbjTime=dayjs.tz(datetime,'Asia/Shanghai');// 东八区时间console.log(`BeijingTime ${datetime} + 1 = `,bjTime.add(1,'d').format('YYYY-MM-DD'));// add one day
// local timezone is Asia/Shanghai , result is right
BeijingTime 2022-10-02 + 1 = 2022-10-03
// local timezone is America/Toronto, result is right
BeijingTime2022-10-02 + 1 = 2022-10-03
Wrong
// local timezone is Australia/Sydney, Output Wrong
BeijingTime 2022-10-02 + 1 = 2022-10-02
How to solve the above problems ???
The text was updated successfully, but these errors were encountered:
The code example is as follows
Wrong
// local timezone is Australia/Sydney, Output Wrong BeijingTime 2022-10-02 + 1 = 2022-10-02
How to solve the above problems ???
The text was updated successfully, but these errors were encountered: