Time, Date, Navigation & Astronomy Clock Time, Elapsed Time & Time Zones ISO 8601 time-of-day and duration conventions

Time Duration Calculator

Enter a start time and an end time and this calculator returns the elapsed span in hours, minutes and seconds, in decimal hours, in minutes and in seconds. It handles the case that trips up most spreadsheets — a shift that ends earlier on the clock than it started, because it ran past midnight — and lets you add whole extra days for spans longer than 24 hours. Deduct an unpaid break in minutes and you get the net worked time that payroll actually pays.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Start hourHour of the start time on a 24-hour clock, so 1 pm is 13.9
Start minuteMinutes past the start hour.0
Start secondSeconds past the start minute; leave at zero unless you are timing to the second.0
End hourHour of the end time on a 24-hour clock; use 0 for midnight at the end of a shift.17
End minuteMinutes past the end hour.30
End secondSeconds past the end minute.0
Extra whole daysWhole days between the two dates. Leave at zero for a same-day or single overnight span; set 2 for a span of two nights and a bit.0
Unpaid breakTotal unpaid break minutes to subtract from the span; enter 0 to see the gross span only.30 min

It returns

  • Net duration — The span between the two times after the break is deducted.
  • Net duration in decimal hours — The figure payroll and invoicing systems expect.
  • Net duration in minutes
  • Net duration in seconds
  • Gross span in decimal hours — Before the break is deducted.
  • Crosses midnight
  • Calendar days spanned — How many midnights fall inside the span.

The formula

net=(3600h2+60m2+s2)(3600h1+60m1+s1)+86400Δd60B
decimal hours=net3600

In plain text: T = (3600h₂ + 60m₂ + s₂) − (3600h₁ + 60m₁ + s₁); if T < 0 and Δd = 0 then T ← T + 86400; gross = T + 86400Δd; net = gross − 60B

  • h₁, m₁, s₁Start hour, minute and second on a 24-hour clock (h, min, s)
  • h₂, m₂, s₂End hour, minute and second (h, min, s)
  • ΔdExtra whole days between the two dates (days)
  • BUnpaid break to deduct (minutes)
  • TElapsed span (seconds)

The +86400 wrap is applied only when no extra days were entered; otherwise the day count already places the end date and no wrap is needed.

Updated Category Clock Time, Elapsed Time & Time Zones Verified against published test cases Reading time 9 min

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.

  1. Start in seconds past midnight. 3600 × 22 + 60 × 15 + 0 = 79,200 + 900 = 80,100 s.
  2. End in seconds past midnight. 3600 × 6 + 60 × 45 + 0 = 21,600 + 2,700 = 24,300 s.
  3. Raw difference. 24,300 − 80,100 = −55,800 s. It is negative, so the shift ran past midnight.
  4. Apply the wrap. −55,800 + 86,400 = 30,600 s gross.
  5. 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.
  6. Deduct the break. 45 × 60 = 2,700 s, so net = 30,600 − 2,700 = 27,900 s.
  7. 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

Each row is the clock span converted to seconds, wrapped past midnight where the end reading is smaller, then reduced by the break.
StartEndCrosses midnightGross hoursBreak (min)Paid hours
09:0017:00No8.00307.50
09:0017:30No8.50308.00
08:0016:30No8.50457.75
06:4515:15No8.50308.00
07:0019:00No12.006011.00
12:0000:00Yes12.006011.00
22:0006:00Yes8.00307.50
22:1506:45Yes8.50457.75
23:3007:45Yes8.25457.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.

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.

Frequently asked questions

How many hours is 9 am to 5:30 pm?

Eight and a half hours gross, or eight hours after a 30-minute break. In seconds: 17:30 is 63,000 s past midnight, 09:00 is 32,400 s, and the difference is 30,600 s = 8.5 h. Deduct 1,800 s for the break and you have 28,800 s, which is exactly 8.00 decimal hours or 480 minutes.

How do I calculate hours for a shift that goes past midnight?

Enter the times as they appear on the clock and let the calculator wrap. When the end reading is numerically smaller than the start, 86,400 seconds are added, which is exactly one day. For 22:15 to 06:45 that gives 30,600 s = 8 h 30 m. Check the result with the two-part method: time to midnight plus time after midnight.

What if the shift is longer than 24 hours?

Use the extra whole days field. The midnight wrap can only ever add one day, so it cannot produce a span above 24 hours on its own. Set extra days to 1 for a shift that runs from Monday morning to Tuesday afternoon, and the wrap is switched off because the day count now places the end date explicitly.

Why is my result negative?

Because the break you entered is longer than the span between the two times. The break box is in minutes, so entering 8 meaning eight hours deducts only eight minutes, while entering 480 deducts the eight hours. If the gross span itself looks wrong, check whether the crosses-midnight flag is showing yes when it should not be.

Does this account for daylight saving time?

No. Every day is treated as exactly 86,400 seconds, so on a transition day the local civil span is an hour longer or shorter than what you see here. A shift running 22:00 to 06:00 across a spring-forward boundary is seven hours of civil time, not eight. Use the daylight saving time change calculator for those dates.

Should I use gross or net hours for payroll?

Net, in almost every case, because unpaid breaks are not worked time. Keep the gross figure too: it is what a clock-in system recorded and it is what any dispute will be reconciled against. The calculator shows both, plus the break as a separate line in the breakdown table, so the deduction is visible rather than buried.

What is 7.75 hours in hours and minutes?

7 hours 45 minutes. Multiply the fractional part by 60: 0.75 × 60 = 45. The reverse trip is the one that goes wrong — 7 h 45 m is 7.75 decimal hours, not 7.45. Any decimal-hours figure whose fractional part is above 0.59 is a giveaway that a sexagesimal value was pasted into a decimal field.

Can I enter times with seconds?

Yes. All three fields accept seconds, and the seconds boxes take decimals for stopwatch work. A span from 07:14:32 to 09:03:07 is 32,587 − 26,072 = 6,515 seconds, which is 1 h 48 m 35 s or 1.809722 decimal hours. Keep the seconds figure if you plan to sum several spans, and convert only at the end.

References