This is a common issue, but the unique aspect of this situation is as follows:
I am attempting to calculate the hours between 12:00 (timeA) and 20:00 (timeB)
. A basic
dayjs(timeA).diff(timeB, 'hours')
yields 8 hours
.
The challenge arises when calculating the hours between 20:00 and 02:00 midnight
, which results in 18 hours
instead of the desired 6 hours
.
Is there a method using dayJs
to achieve the correct calculation in this scenario?