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
I have the following code fragment in a node.js based backend written in Typescript to calculate the difference between two DateTimes:
import dayjs from 'dayjs'
import duration from 'dayjs/plugin/duration'
import utc from 'dayjs/plugin/utc'
import timezone from 'dayjs/plugin/timezone'
...
dayjs.extend(duration)
dayjs.extend(utc)
dayjs.extend(timezone)
...
const date1 = dayjs().utc().local().tz('Europe/Berlin');
const date2 = dayjs('2025-03-13T00:00:00').utc().local().tz('Europe/Berlin')
const diff = dayjs.duration(date2.diff(date1))
console.info('date1', date1.format());
console.info('date2', date2.format());
console.info('diff:\n', diff);
This returns the wrong number of hours (console-output):
date1 2024-11-01T08:27:46+01:00
date2 2025-03-13T00:00:00+01:00
diff:
l {
'$d': {
years: 0,
months: 4,
days: 9, // <== This is wrong
hours: 23, // <= This is wrong
minutes: 32,
seconds: 13,
milliseconds: 588
},
'$l': 'en',
'$ms': 11374333588
}
Additional information
Up to dayjs v.1.11.9 it works as expected. From v.1.11.10 to 1.11.13 it does not calculate correctly.
Information
Day.js Version v1.11.10 - v1.11.13
OS: macOS 15.1
Browser n/a (node.js v23.0.0)
Time zone: GMT+1 (CET)
The text was updated successfully, but these errors were encountered:
rseiffert
changed the title
diff and duration calculate wrong days & hours
diff and duration calculate wrong days & hours (from v1.11.10 to v1.11.13)
Nov 1, 2024
rseiffert
changed the title
diff and duration calculate wrong days & hours (from v1.11.10 to v1.11.13)
diff and duration calculates wrong days & hours (from v1.11.10 to v1.11.13)
Nov 1, 2024
Describe the bug
I have the following code fragment in a node.js based backend written in Typescript to calculate the difference between two DateTimes:
This returns the wrong number of hours (console-output):
This results in
(wrong numbers in bold)
Expected behavior
The correct result would be
Additional information
Up to dayjs v.1.11.9 it works as expected. From v.1.11.10 to 1.11.13 it does not calculate correctly.
Information
The text was updated successfully, but these errors were encountered: