I have two dates in Javascript (a starting date, and an end date), and I want to get how much time passed between 2 hours within that time range. The hours are 23 (11pm) and 06 (6am).

So, if the starting date is

Oct, 15 - 20:00

And the end date is:

Oct, 19 - 04:15

The result would be

26 hs and 15 min

15/10 to 16/10 --> 23 - 6:00  :   7:00 hours
16/10 to 17/10 --> 23 - 6:00  :   7:00 hours
17/10 to 18/10 --> 23 - 6:00  :   7:00 hours
18/10 to 19/10 --> 23 - 4:15  :   5:15 hours
--------------------------------------------
                                 26:15 hours

I hope it's clear!

0 Answers