Calculate Hours Between Two Times, Including Overnight Shifts
The gap between two times of day is simple arithmetic until the clock resets at midnight. Review the wrap rule, the equal-times case, and decimal hours for payroll.
Subtracting two clock times is easy until the clock resets. From 09:00 to 17:30 the arithmetic is what you expect. From 22:00 to 06:00 it is not: the end is a smaller number than the start, and the plain subtraction gives minus sixteen hours rather than eight.
The fix is to notice that the end fell on the next day and add twenty-four hours. This page does that automatically, and the setting that controls it has three positions rather than a checkbox because the three cases are genuinely different. Auto wraps only when the end is not after the start. Always treats the end as being on the next day whatever the numbers say, so 09:00 to 17:00 becomes thirty-two hours. Never refuses to wrap at all and tells you the times look reversed.
One case is worth stating because a lot of calculators get it wrong: two identical times. A shift from 09:00 to 09:00 is twenty-four hours, not zero. Returning zero would silently lose a whole day from a timesheet, which is the kind of error nobody catches until payroll.
The other quiet trap is the twelve-hour clock. 12:00 am is midnight and 12:00 pm is noon — neither is twelve o'clock plus an offset, and adding twelve to the hour gets both of them wrong. Both are handled.
Decimal hours sits under the main answer because it is what the next step usually needs. Eight hours and thirty minutes is 8.5 on a timesheet, not 8.3, and that particular slip is common enough to be worth removing.
A spreadsheet can do this with a formula that handles the midnight wrap, which is a formula most people look up each time. A phone's clock app gives a stopwatch, not a subtraction between two times you already know.
On FindUtils, Date Difference Calculator is the tool to use when the two moments are on different dates — it takes full date-times and returns years down to seconds. This page is for the case where there is no date at all, only two readings from a clock. If you need a whole week of entries with overtime and pay, Timesheet Calculator is the one.