What elapsed time is, and why midnight breaks it
Elapsed time is the difference between two instants. When both instants are clock readings on the same day, subtracting them is trivial. The problem is that a clock reading is not an instant — it is a position on a repeating 24-hour cycle, and 06:45 could be nine hours after 21:45 or fifteen hours before it. Nothing in the two readings alone tells you which.
Every tool that computes a shift length has to resolve that ambiguity with a rule. The rule almost everyone uses, and the one this calculator uses, is that if the end reading is numerically smaller than the start reading, the span ran past exactly one midnight. That is right for the overwhelming majority of real shifts, journeys and race legs, and it is what gives 22:15 to 06:45 the correct answer of 8 h 30 m rather than a nonsensical −15 h 30 m.
The rule fails when a span genuinely lasts more than 24 hours — a 30-hour on-call block, a three-day expedition, a machine run over a weekend. That is why the extra-whole-days field exists. Set it and the wrap rule is switched off, because the day count now places the end date explicitly and there is nothing left to guess.
Once you have the span in seconds, everything else is division. Divide by 60 for minutes, by 3,600 for decimal hours, and subtract 60 times the break minutes to get the net figure. If you want to combine several such spans afterwards, the add and subtract time calculator does that without the midnight rule getting in the way.
The formula, one variable at a time
Both clock readings become seconds past midnight: s = 3600h + 60m + s. A 24-hour clock is assumed throughout, so 1 pm is 13 and midnight at the end of a shift is 0. The subtraction T = end − start is then an ordinary integer subtraction with no borrowing.
If T comes out negative and you entered no extra days, 86,400 seconds are added — exactly one day — and the calculator flags that it did so. That flag matters: it is the one place where the tool made a decision on your behalf, and you should confirm it matches what actually happened.
Extra whole days Δd add 86,400Δd seconds. Note that this is 24 hours of clock time per day, not 24 hours of civil time. On the day a daylight-saving transition takes effect, the local civil day is 23 or 25 hours long, and this calculator will be out by one hour across that boundary. The daylight saving time change calculator is the tool for that case.
Finally the break: net = gross − 60B, with B in minutes. The break is treated as a single lump, so two 15-minute breaks and one 30-minute break are the same input. Nothing here knows about jurisdiction-specific rules on whether a break is paid; you decide what to enter.
Worked example: a night shift from 22:15 to 06:45 with a 45-minute break
A warehouse operative clocks on at 22:15 and off at 06:45 the following morning, with 45 minutes of unpaid break.
- Start in seconds past midnight. 3600 × 22 + 60 × 15 + 0 = 79,200 + 900 = 80,100 s.
- End in seconds past midnight. 3600 × 6 + 60 × 45 + 0 = 21,600 + 2,700 = 24,300 s.
- Raw difference. 24,300 − 80,100 = −55,800 s. It is negative, so the shift ran past midnight.
- Apply the wrap. −55,800 + 86,400 = 30,600 s gross.
- Check it another way. From 22:15 to midnight is 105 minutes; from midnight to 06:45 is 405 minutes; 105 + 405 = 510 minutes = 30,600 s. The two methods agree.
- Deduct the break. 45 × 60 = 2,700 s, so net = 30,600 − 2,700 = 27,900 s.
- Convert. 27,900 / 3,600 = 7.75 decimal hours, which is 7 h 45 m 00 s.
The gross span is 8.5 hours and the paid time is 7.75 hours. If the same operative worked the same pattern five nights a week, the weekly paid total is 5 × 7.75 = 38.75 hours — and quoting that as “38 hours 75 minutes” rather than 38 h 45 m is the classic decimal-versus-sexagesimal slip.
Common shift patterns: gross span, break and paid hours
| Start | End | Crosses midnight | Gross hours | Break (min) | Paid hours |
|---|---|---|---|---|---|
| 09:00 | 17:00 | No | 8.00 | 30 | 7.50 |
| 09:00 | 17:30 | No | 8.50 | 30 | 8.00 |
| 08:00 | 16:30 | No | 8.50 | 45 | 7.75 |
| 06:45 | 15:15 | No | 8.50 | 30 | 8.00 |
| 07:00 | 19:00 | No | 12.00 | 60 | 11.00 |
| 12:00 | 00:00 | Yes | 12.00 | 60 | 11.00 |
| 22:00 | 06:00 | Yes | 8.00 | 30 | 7.50 |
| 22:15 | 06:45 | Yes | 8.50 | 45 | 7.75 |
| 23:30 | 07:45 | Yes | 8.25 | 45 | 7.50 |
The 12:00 to 00:00 row is the case people most often get wrong: an end reading of 00:00 is numerically smaller than the start, so the wrap applies and the span is 12 hours, not zero.
How to read the result
Read the crosses-midnight flag before you read anything else. If it says yes and your shift did not run overnight, your start and end are in the wrong boxes, and the answer will be out by exactly 24 hours minus the true span. That single check catches almost every wrong result this calculator can produce.
The gross figure is what a clock-in system records; the net figure is what payroll pays. Keep both. Disputes over hours are usually disputes about the break, not about the clock readings, and quoting a single net number gives you nothing to reconcile against.
A negative net duration means the break you entered exceeds the span between the two times. That is arithmetic, not a bug, and the calculator warns about it. It usually means a break was entered in hours instead of minutes — 8 in the break box is eight minutes here, not eight hours.
For decimal hours, two decimal places resolve to 36 seconds and three to 3.6 seconds. Payroll rules vary on rounding: some employers round each shift to the nearest quarter hour, some to the nearest minute, some not at all. Round once, at the end, according to whatever rule applies to you — never round the intermediate seconds figure, because the error accumulates across a week.
Assumptions and limits of this calculator
- Every day is treated as exactly 86,400 seconds. On a daylight-saving transition day, local civil time runs 23 or 25 hours and this calculator will be an hour out across the boundary.
- The two times are assumed to be in the same time zone. If they are not, convert one of them first with the time zone converter — subtracting two readings from different zones is meaningless.
- Only one midnight is inferred. A span longer than 24 hours needs the extra-days field; the wrap rule alone can never produce a result above 24 hours.
- The break is a single unpaid lump. Split breaks, paid rest breaks and jurisdiction-specific minimums are not modelled; enter the total you actually want deducted.
- Leap seconds are ignored. A minute is 60 seconds and an hour is 3,600, matching every clock-in system in use.
- No overtime rules are applied. The result is elapsed time, not pay; premium rates, daily and weekly thresholds are entirely outside this calculation.
ISO 8601 and the 24:00 convention
ISO 8601 allows both 00:00 and 24:00 to denote midnight, distinguished by which end of the day you mean: 24:00 on one date is the same instant as 00:00 on the next. Because this calculator's hour field is capped at 23, enter a shift ending at midnight as 00:00 and let the wrap rule handle it — the answer is identical, and it is why the 12:00 to 00:00 row in the reference table shows twelve hours rather than zero.
Related tools and when to use each
This calculator answers “how long between these two clock times”. When you already have several lengths and want their total, the add and subtract time calculator sums durations without any midnight rule. When you only need the sexagesimal-to-decimal conversion, the minutes to decimal hours calculator does that one step.
For spans measured in days rather than hours, the age in days calculator counts calendar days directly and avoids the 86,400-second-per-day assumption entirely. Software engineers reconciling log timestamps should work in epoch seconds instead, which the Unix timestamp converter handles — epoch time has no time zone and no midnight ambiguity, which is exactly why systems store it that way.
Spreadsheets can reproduce this calculation with =MOD(end-start,1), which applies the same wrap rule, and multiplying by 24 gives decimal hours. The naive =end-start returns a negative number for overnight shifts and displays as a string of hash marks, which is the spreadsheet's way of saying it cannot show a negative time.
