Time Duration Calculator Explained: Hours, Minutes, and Midnight Crossings
How elapsed time between two clock readings is calculated — the minute-since-midnight trick every date library uses, the 24-hour shift-work convention that keeps overnight results positive, and the payroll-friendly decimal hours output.
What a time duration calculator actually computes
A time duration calculator turns two clock readings into a single elapsed span. Give it a start time and an end time, and it tells you how many hours and minutes are between them. The time duration calculator returns the answer three ways — hours-and-minutes for human reading, decimal hours for payroll and invoicing, and total minutes (or seconds) for anyone who needs a single number.
The reason a dedicated tool is faster than mental arithmetic is that clock time is base-60, not base-10. Subtracting 09:15 from 17:30 looks trivial until you try “09:45 to 17:15” and end up borrowing across the hour column. Overnight spans make it worse: 22:00 to 06:30 has no obvious answer without either drawing a number line or accepting negative time. The calculator handles all of this in one step, using the same convention every date library and payroll system agrees on.
How duration between two times is calculated
The standard algorithm converts each clock reading to “minutes past midnight,” subtracts, and formats the result. It is the same three lines of arithmetic used by java.time.Duration.between, Python’s datetime module, JavaScript’s date-fns, and every spreadsheet =B1-A1 formula when the cells are formatted as time.
The formal steps are:
- Convert the start time to minutes past midnight: hours × 60 + minutes. So 09:15 becomes 555.
- Convert the end time the same way. 17:30 becomes 1050.
- Subtract: end minus start. 1050 − 555 = 495 minutes.
- If the result is negative (i.e. end is earlier than start), add 1440 — the number of minutes in a full day — and flag the span as crossing midnight.
- Format the total minutes as hours and minutes: 495 / 60 = 8 remainder 15, so 8h 15m. The decimal form is 495 / 60 = 8.25.
The +1440 rule is the one convention people occasionally argue about. The alternative — returning a negative number and letting the user figure out that the shift ran overnight — is technically correct but useless in practice. Nobody schedules a shift from 22:00 to 06:30 with the intention that it means “fifteen and a half hours backwards in time.” The +1440 convention matches how humans talk, how payroll systems reconcile timesheets, and how Google’s answer box responds when you type “hours between 10pm and 6:30am.”
Worked example
Take a standard office day: start at 09:15, end at 17:30.
- Start in minutes past midnight: 9 × 60 + 15 = 555.
- End in minutes past midnight: 17 × 60 + 30 = 1050.
- Difference: 1050 − 555 = 495 minutes.
- Hours and minutes: 495 ÷ 60 = 8 remainder 15, so 8h 15m.
- Decimal hours: 495 ÷ 60 = 8.25.
Now the overnight case — a night-shift nurse working 22:00 to 06:30 the next morning.
- Start: 22 × 60 + 0 = 1320.
- End: 6 × 60 + 30 = 390.
- 390 < 1320, so the calculator adds 1440: end becomes 390 + 1440 = 1830.
- Difference: 1830 − 1320 = 510 minutes.
- Hours and minutes: 510 ÷ 60 = 8 remainder 30, so 8h 30m. Decimal form: 8.5.
Plug either pair of values into the time duration calculator and you get the same numbers with the “crosses midnight” flag lit up on the second one.
Factors that affect the duration you record
Which clock the times are in
The calculator does not know or care what time zone the two readings are in — it just subtracts them. That is fine for a shift, meeting, or sleep that stays within one time zone. It is a problem for a long-haul flight where you record boarding time in one place and landing time in another. In that case, convert both readings to a single reference time zone (usually UTC) before entering them.
Whether the span crosses midnight
Same-day and overnight spans use different arithmetic, and the calculator switches automatically when the end reads earlier than the start. If you enter 08:00 and 04:00 by accident when you meant 08:00 and 20:00 (4pm), the tool will confidently return 20h 00m and mark the span as crossing midnight. The output is only as good as the input; always double-check that you have used the 24-hour clock correctly.
Whether you record the boundary
Timekeeping in payroll usually treats the start and end readings as instants, not intervals. A shift “09:00 to 17:00” is 8 hours — you are not paid for both the 09:00 clock-in and the 17:00 clock-out as two separate hours. This is different from calendar-day counting, where the boundary sometimes gets included or excluded depending on convention.
Rounding rules at your employer
Many employers round timesheet entries to the nearest 5, 6, or 15 minutes. The US Fair Labor Standards Act allows rounding to the nearest 15 minutes as long as it does not systematically shortchange the employee — see the US Department of Labor’s guidance on hours worked. The calculator returns exact numbers; your payroll system may apply its own rounding on top.
Unpaid breaks
Duration is gross time on the clock. If your shift includes a 30-minute unpaid lunch break, subtract it after the calculator returns the total — or run the calculation twice, once for the pre-break span and once for the post-break span, then add.
How to get the most out of a duration calculation
- Use 24-hour input. Convert AM/PM in your head first. 5:30 PM is 17:30. The single biggest source of duration-calculation errors is entering PM times as if they were AM.
- Round only at the end. If you need to round to the nearest 15 minutes, do it after the exact calculation, not before. Rounding both endpoints before subtracting can produce errors of up to 30 minutes.
- Pick the right output for the job. For a human-readable answer (“how long was the meeting?”), use hours and minutes. For payroll or invoicing, use decimal hours. For anything you need to add or divide further, use total minutes.
- For overnight sleep, ignore the midnight flag. The +1440 adjustment is what you want — sleep from 23:00 to 07:00 is 8 hours, exactly as the calculator reports.
- Cross-check with a spreadsheet. In Excel or Google Sheets, format two cells as
hh:mm, enter the two times, and the difference — formatted as[h]:mmto allow > 24 hours — will match the calculator to the minute. This is a good sanity check for shift-work spreadsheets built by hand. - For much longer spans, use a date tool. The days between dates calculator and date calculator take full calendar dates and are the right instruments once your span passes 24 hours.
Common mistakes
Entering PM as AM. The most common duration-calculation error is treating 5:30 PM as 5:30 instead of 17:30. In the same-day case the calculator will cheerfully return a negative-ish number by triggering the midnight-crossing branch, and you will get 18h 15m for what was supposed to be an 8-hour day.
Forgetting an unpaid break. The calculator does not know your lunch break existed. If you clocked in at 09:00 and out at 17:30 with a 45-minute unpaid lunch, the gross duration is 8h 30m but the paid duration is 7h 45m. Some payroll systems handle this for you; others expect the deduction on the timesheet.
Adding a midnight-crossing shift to itself. Two consecutive night shifts each get calculated as one span. Do not naively sum “22:00 to 06:30” twice by adding the clock readings — the arithmetic breaks. Compute each shift separately and add the two duration results.
Using clock arithmetic on days. If a span is more than 24 hours long — a hospital stay from 3pm Tuesday to 8am Thursday, say — this calculator cannot help. It only accepts times of day. Use days between dates or a full-datetime tool instead.
When to seek professional advice
Duration arithmetic is not the sort of thing that usually needs an expert — it is base-60 subtraction with a wrap-around rule. But if you are reconciling contested timesheets, or a dispute over billable hours has legal implications, get a payroll or employment specialist to review the underlying records rather than relying on any online calculator. The maths is the easy part; the evidence of what actually happened at the start and end of the shift is the hard part.
Frequently asked questions
How do I enter times after noon?
Use the 24-hour clock. 1:00 PM is 13:00, 5:30 PM is 17:30, and 11:45 PM is 23:45. This is the same convention used by ISO 8601, aviation, the military, and everyday life across most of Europe and Asia. It avoids the AM/PM ambiguity that is the single most common source of clock-arithmetic mistakes.
What if my end time is earlier than my start time?
The calculator assumes the end is on the following calendar day and adds 24 hours automatically. So 22:00 to 06:30 returns 8h 30m, not a negative number. This matches how people describe overnight shifts, sleep durations, and red-eye flights. If you genuinely wanted the same-day gap in reverse, swap the two inputs.
Why is decimal hours useful?
Because most payroll systems, freelance invoicing tools, and time-tracking apps store hours as a decimal number rather than hours-and-minutes. 8h 15m is 8.25 decimal hours; 8h 30m is 8.5; 8h 45m is 8.75. If you bill in six-minute increments (0.10 hours), the decimal figure is what goes on the invoice.
Can it handle durations longer than 24 hours?
No — the input is two times of day, not two full datetimes, so the maximum result is just under 24 hours (23h 59m). For anything longer, use a days between dates calculator that takes full dates.
Does daylight saving time affect the result?
The calculator works on raw clock readings, not real elapsed wall-clock time. On the two days a year that the clocks change, actual elapsed time between two given clock readings shifts by one hour. For every other day — 363 out of 365 — the clock-time result is identical to the real elapsed time.
What is the difference between this and a stopwatch?
A stopwatch measures a live-running interval to the second or millisecond; this calculator works from two clock readings you already have. If you know the start and end were 09:15 and 17:30 respectively, this tool is faster. If you are timing something as it happens and need sub-second precision, a stopwatch is the right instrument.
How does the calculator handle midnight exactly?
Midnight at the start of the day is entered as 00:00; midnight at the end of the day is not a separate value — you would enter it as 00:00 with the end time earlier, prompting a next-day crossing. If you need the duration from 00:00 to 24:00, the answer is simply 24h 00m, which is beyond the calculator’s single-day range; a shift starting at 00:00 usually ends earlier than 24:00 so this edge case rarely comes up in practice.
Related calculators
- Time Duration Calculator — the parent tool this article explains.
- Time Unit Converter — switch between seconds, minutes, hours, and days.
- Days Between Dates — count calendar days across a longer span.
- Date Calculator — add or subtract days from any starting date.
- Workday Calculator — count business days between two dates.
- Age Calculator — exact age in years, months, and days.
Frequently asked questions
How do I enter times after noon?
Use the 24-hour clock. 1:00 PM is 13:00, 5:30 PM is 17:30, and 11:45 PM is 23:45. This is the same convention used by ISO 8601, aviation, the military, and everyday life across most of Europe and Asia. It avoids the AM/PM ambiguity that is the single most common source of clock-arithmetic mistakes.
What if my end time is earlier than my start time?
The calculator assumes the end is on the following calendar day and adds 24 hours automatically. So 22:00 to 06:30 returns 8h 30m, not a negative number. This matches how people describe overnight shifts, sleep durations, and red-eye flights. If you genuinely wanted the same-day gap in reverse, swap the two inputs.
Why is decimal hours useful?
Because most payroll systems, freelance invoicing tools, and time-tracking apps store hours as a decimal number rather than hours-and-minutes. 8h 15m is 8.25 decimal hours; 8h 30m is 8.5; 8h 45m is 8.75. If you bill in six-minute increments (0.10 hours), the decimal figure is what goes on the invoice.
Can it handle durations longer than 24 hours?
No — the input is two times of day, not two full datetimes, so the maximum result is just under 24 hours (23h 59m). For anything longer, use a days-between-dates calculator that takes full dates.
Does daylight saving time affect the result?
The calculator works on raw clock readings, not real elapsed wall-clock time. On the two days a year that the clocks change, actual elapsed time between two given clock readings shifts by one hour. For every other day — 363 out of 365 — the clock-time result is identical to the real elapsed time.
What is the difference between this and a stopwatch?
A stopwatch measures a live-running interval to the second or millisecond; this calculator works from two clock readings you already have. If you know the start and end were 09:15 and 17:30 respectively, this tool is faster. If you are timing something as it happens and need sub-second precision, a stopwatch is the right instrument.
How does the calculator handle midnight exactly?
Midnight at the start of the day is entered as 00:00; midnight at the end of the day is not a separate value — you would enter it as 00:00 with the end time earlier, prompting a next-day crossing. If you need the duration from 00:00 to 24:00, the answer is simply 24h 00m, which is beyond the calculator’s single-day range; a shift starting at 00:00 usually ends earlier than 24:00 so this edge case rarely comes up in practice.
Informational only. Not personalised financial, legal, or tax advice.