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
Describe the bug
On a machine that does not have daylight saving time active (ie, if on the US east coast on March 11, 2022), converting a dayjs object with a date that has Daylight Saving time active (ie: March 15, 2022) to a JS Date object results in the time being incorrect
const testTime = dayjs('03-15-2022 09:30:00').tz('America/New_York');
console.log('DayJS', testTime.format()); <- output: 'DayJS 2022-03-15T09:30:00-04:00'
console.log('JS Date', testTime.toDate()); <- output: 'JS Date Tue Mar 15 2022 08:30:00 GMT-0400 (Eastern Daylight Time)'
In this example the JS Date has a time one hour earlier than expected
NOTE: Setting system date to 3/15/2022 solves the issue, but for obvious reasons that's not really a fix.
WORKAROUND:
You can get the correct result if you convert the Dayjs object to a string, ie: new Date(testTime.format('ddd MMM DD YYYY HH:mm:ss Z')) <- this produces the correct result
The text was updated successfully, but these errors were encountered:
Describe the bug
On a machine that does not have daylight saving time active (ie, if on the US east coast on March 11, 2022), converting a dayjs object with a date that has Daylight Saving time active (ie: March 15, 2022) to a JS Date object results in the time being incorrect
Expected behavior
The time should be correct
Information
WORKAROUND:
You can get the correct result if you convert the Dayjs object to a string, ie:
new Date(testTime.format('ddd MMM DD YYYY HH:mm:ss Z'))
<- this produces the correct resultThe text was updated successfully, but these errors were encountered: