iamkun / dayjs

⏰ Day.js 2kB immutable date-time library alternative to Moment.js with the same modern API
https://day.js.org
MIT License
47.06k stars 2.31k forks source link

Wrong timezone conversation? #2431

Open Relvl opened 1 year ago

Relvl commented 1 year ago

Describe the bug

    logInfo("Ex: %s", dayjs.utc("2023-08-27T11:01:01Z").format("DD-MM-YYYY hh:mm Z"));
    logInfo("Ex: %s", dayjs.utc("2023-08-27T11:01:01Z").tz(timeZone).format("DD-MM-YYYY hh:mm Z"));
    logInfo("Ex: %s", dayjs.utc("2023-08-27T11:01:01Z").local().format("DD-MM-YYYY hh:mm Z"));

Shows:

Ex: 27-08-2023 11:01 +00:00
Ex: 27-08-2023 04:01 +05:00
Ex: 27-08-2023 04:01 +05:00

Expected behavior Obviously, 11:01:00 GMT is NOT 04:01:00 +0500, it is 16:01:00 +0500

Information

cp3hnu commented 1 year ago

Should be format("DD-MM-YYYY HH:mm Z")); hh: 01-12 HH: 01-23