How to Use This Time Duration Calculator
The time duration calculator on this page finds elapsed hours, minutes, and seconds between any two times. Enter your start and end time using the dropdowns, choose 12-hour or 24-hour format, and instantly see the elapsed time plus the total in decimal hours, total minutes, and total seconds. If your end time is earlier than your start time, the calculator automatically assumes the duration crosses midnight. For tracking hours across multiple days, also see our time card calculator.
How to Calculate Time Duration
The formula for time duration is straightforward: subtract the start time from the end time, converting to a common unit (total seconds) first.
Step-by-Step Formula
- Convert start time to total seconds: (H × 3600) + (M × 60) + S
- Convert end time to total seconds the same way
- Subtract start seconds from end seconds
- If the result is negative (crosses midnight), add 86,400 seconds (24 hours)
- Convert back: hours = ⌊total ÷ 3600⌋, minutes = ⌊(remainder) ÷ 60⌋, seconds = remainder
Example: 9:15 AM to 5:45 PM
Start: 9 × 3600 + 15 × 60 = 33,300 seconds. End: 17 × 3600 + 45 × 60 = 63,900 seconds. Difference: 63,900 − 33,300 = 30,600 seconds = 8 hours 30 minutes.
Common Time Duration Examples
Here are some frequently calculated durations:
- 9:00 AM to 5:00 PM — 8 hours 0 minutes (standard workday)
- 8:30 AM to 4:30 PM — 8 hours 0 minutes (with same lunch deduction)
- 7:00 AM to 3:30 PM — 8 hours 30 minutes
- 10:00 PM to 6:00 AM — 8 hours 0 minutes (overnight/midnight crossing)
- 1:00 PM to 1:00 AM — 12 hours 0 minutes
For payroll purposes, it is common to convert the duration to decimal hours — for example, 8 hours 30 minutes = 8.50 hours. Use our time to decimal calculator for that conversion. If any hours in your shift qualify as overtime, our time and a half calculator will compute the overtime pay rate.
How to Calculate Elapsed Time Across Midnight
When a shift or event spans midnight, the end time will appear earlier than the start time. The trick is to add 24 hours (86,400 seconds) to the end time before subtracting. For example:
- Start: 11:00 PM (23:00), End: 7:00 AM (07:00)
- End is earlier, so add 24h: 7:00 AM becomes 31:00 (07:00 + 24:00)
- Duration: 31:00 − 23:00 = 8 hours
This calculator handles midnight crossings automatically — just enter the real start and end times and it will detect the crossing.
Time Duration vs. Elapsed Time
The terms "time duration" and "elapsed time" are interchangeable in everyday use. Both describe the span of time between two specific moments. "Duration" is typically used to describe the length of a scheduled event (a 90-minute movie, a 3-hour exam), while "elapsed time" is more common in measurement contexts (elapsed time of a race, time elapsed since an event started). Mathematically, both are calculated the same way. When a duration spans multiple time zones — such as an international flight — use our time zone converter to reconcile local times before computing the difference.
Time Duration Formula Summary
The core formula used by this calculator:
- Total seconds = (endH × 3600 + endM × 60 + endS) − (startH × 3600 + startM × 60 + startS)
- If total seconds < 0, add 86,400 (midnight crossing)
- Hours = Math.floor(totalSeconds ÷ 3600)
- Minutes = Math.floor((totalSeconds mod 3600) ÷ 60)
- Seconds = totalSeconds mod 60
- Decimal hours = totalSeconds ÷ 3600
Need to track durations across multiple shifts or days? Our average time calculator can find the mean of several time values — useful for averaging shift lengths or meeting durations.
Sources & References
- NIST Time and Frequency Division — National Institute of Standards and Technology
- International System of Units (SI) — NIST