Home Calculators Categories Category: Everyday Life, Personal & Utility

Time Duration Calculator

This calculator returns the exact elapsed interval between two moments, either two clock times or two dated timestamps, and optionally subtracts a break. Every figure is derived from integer seconds, so the same inputs always produce the same output with no rounding drift. It runs entirely in your browser: no network requests, no remote APIs, and it works offline once the page has loaded.

Input
Load a daytime, overnight or leap-day example. Editing any value changes the selection to Custom.
Start of the interval. Your device may show AM/PM or 24-hour time. Seconds are optional.

Use AM/PM if shown by your device. Seconds are optional.

End of the interval. Select Next day for overnight times, or use Dates & times for dated intervals.
Same day adds no days. Next day adds 24 hours before subtracting the clock values. Equal times give zero or 24 hours respectively.
Sum all breaks in whole minutes. Enter zero for none. The slider starts at 0–240 minutes and expands for larger typed values, up to 1000000.
min

Whole minutes. Enter 0 for no break.

Visual
Interval and break comparison Enter a valid interval to see the net duration and total break. BEFORE BREAKS — After breaks: — Break: — Break position is illustrative.
Output
Duration after breaks
—

Enter the interval above.

—
Before breaks
—
Break deducted
—
Decimal hours
—
Total minutes
—
Total seconds

Wall-clock calculation: every day is 24 hours. No time-zone, daylight-saving or leap-second adjustments.

How the Calculation Works Internally

All arithmetic is performed on whole seconds. Times are converted to seconds from midnight, dates are converted to absolute day ordinals, and only the final display step divides or formats.

Constant Value in seconds
1 minute 60
1 hour 3,600
1 day 86,400

The start and end clock times become:

Sstart=3600×H1+60×M1+S1S_{\text{start}} = 3600 \times H_1 + 60 \times M_1 + S_1
Send=3600×H2+60×M2+S2S_{\text{end}} = 3600 \times H_2 + 60 \times M_2 + S_2

The gross interval combines the day gap Δdays\Delta_{\text{days}} with the two clock offsets:

Sgross=(Δdays×86400)+Send−SstartS_{\text{gross}} = (\Delta_{\text{days}} \times 86400) + S_{\text{end}} - S_{\text{start}}

Subtracting the break gives the net interval:

Sbreak=Mbreak×60Snet=Sgross−SbreakS_{\text{break}} = M_{\text{break}} \times 60 \qquad S_{\text{net}} = S_{\text{gross}} - S_{\text{break}}

Because integers are exact, there is no cumulative floating-point error. Division happens only when producing the displayed metrics, which are shown to at most 4 decimal places with trailing zeros removed.

Two Modes: Clock Times and Dates & Times

Clock Times (default)

Enter a start time and an end time between 00:00:00 and 23:59:59, in HH:mm or HH:mm:ss form. The defaults are 09:00 and 17:30. An End day selector chooses between Same day and Next day; date fields are hidden in this mode, so Δdays\Delta_{\text{days}} is 0 or 1.

Dates & Times

Switch to this mode to enter a start date and an end date, both between 1900-01-01 and 2100-12-31, alongside the same time fields. The End day selector is hidden here, and the day gap is strictly:

Δdays=Ordinal(Y2,M2,D2)−Ordinal(Y1,M1,D1)\Delta_{\text{days}} = \text{Ordinal}(Y_2, M_2, D_2) - \text{Ordinal}(Y_1, M_1, D_1)

The end timestamp must be at or after the start timestamp. The defaults are 2026-01-01 and 2026-01-02.

Calculating Hour Duration: Sexagesimal Time vs. Decimal Hours

Clock time is sexagesimal (base 60), while payroll, billing, and spreadsheets generally want base 10. The calculator reports both from the same SnetS_{\text{net}}:

Decimal Hours=Snet3600Total Minutes=Snet60\text{Decimal Hours} = \frac{S_{\text{net}}}{3600} \qquad \text{Total Minutes} = \frac{S_{\text{net}}}{60}
Formatted Duration=⌊Snet/3600⌋h ⌊(Snet mod 3600)/60⌋m (Snet mod 60)s\text{Formatted Duration} = \lfloor S_{\text{net}} / 3600 \rfloor\text{h } \lfloor (S_{\text{net}} \bmod 3600) / 60 \rfloor\text{m } (S_{\text{net}} \bmod 60)\text{s}

The formatted breakdown never rolls over at 24 hours, so a 48-hour interval displays as 48h 0m 0s rather than "2 days". Total seconds is always an exact integer.

A common mistake is reading 7:30 as 7.30 hours. Thirty minutes is half an hour, so 7 hours 30 minutes is 7.5 decimal hours. Use this lookup for the minute part of any duration:

Minutes Decimal hours
5 0.0833
6 0.1
10 0.1667
15 0.25
20 0.3333
30 0.5
45 0.75
50 0.8333

Values such as 5 and 10 minutes are repeating decimals, which is why results are capped at 4 places. The underlying seconds value remains exact, so rounding only ever affects what you read, not what is computed.

Overnight Shifts: Spanning Midnight Without Errors

Clock times alone carry no date, so a start of 22:00 and an end of 06:00 is ambiguous. The calculator resolves it with the End day selector:

  • Same day: the end time must be greater than or equal to the start time. If it is earlier, the tool returns "End is before start. Choose Next day for an overnight interval." If the times are equal, the interval is 0 seconds.
  • Next day: exactly 86,400 seconds are added. If start and end are identical, the interval is exactly 24 hours.

For 22:00 to 06:00 on the next day:

Sgross=86400+21600−79200=28800 s=8hS_{\text{gross}} = 86400 + 21600 - 79200 = 28800 \text{ s} = 8\text{h}

Forcing an explicit choice prevents the silent wrap-around that makes many spreadsheet formulas return negative or wrong values after midnight.

Elapsed Duration Between Two Dates and Leap Year Handling

For intervals longer than a day, dates are mapped to ordinals using proleptic Gregorian rules, meaning the current leap-year logic is applied to all years in range:

Ordinal(Y,M,D)=365(Y−1)+⌊Y−14⌋−⌊Y−1100⌋+⌊Y−1400⌋+∑daysBeforeMonth+D−1\text{Ordinal}(Y, M, D) = 365(Y - 1) + \left\lfloor\frac{Y - 1}{4}\right\rfloor - \left\lfloor\frac{Y - 1}{100}\right\rfloor + \left\lfloor\frac{Y - 1}{400}\right\rfloor + \sum \text{daysBeforeMonth} + D - 1

A year is a leap year if it is divisible by 4, except century years, which must also be divisible by 400. See the US Naval Observatory for background on the Gregorian calendar.

Year Divisible by 4 Divisible by 100 Divisible by 400 Leap year
1900 Yes Yes No No
2000 Yes Yes Yes Yes
2024 Yes No n/a Yes
2100 Yes Yes No No

Consider 2024-02-28 00:00 to 2024-03-01 00:00. The interval crosses 28 February, the leap day 29 February, and reaches 1 March, so Δdays=2\Delta_{\text{days}} = 2:

Sgross=2×86400+0−0=172800 s=48h 0m 0sS_{\text{gross}} = 2 \times 86400 + 0 - 0 = 172800 \text{ s} = 48\text{h } 0\text{m } 0\text{s}

That is 48 decimal hours and 2,880 minutes. In a non-leap year the same dates would span only 1 day. The tool also validates each date, so an impossible input such as 2023-02-29 is rejected instead of being silently adjusted.

Deducting Breaks: Net Work Intervals and Timesheet Math

The Total break field accepts whole minutes from 0 to 1,000,000, with a slider covering 0 to 240 minutes and a number input for larger values. The default is 30 minutes. The break is subtracted from the gross interval as a single lump sum:

Snet=Sgross−60×Mbreak,valid only if Sbreak≤SgrossS_{\text{net}} = S_{\text{gross}} - 60 \times M_{\text{break}}, \qquad \text{valid only if } S_{\text{break}} \le S_{\text{gross}}

If the break exceeds the gross interval, the tool reports "Total break cannot exceed the interval before breaks." Combine all meal and rest periods into one number before entering them.

Shift Mode and End day Break Gross Net Decimal hours
09:00 to 17:30 Clock, Same day 30 min 8h 30m 8h 0m 8
22:00 to 06:00 Clock, Next day 30 min 8h 0m 7h 30m 7.5
08:00 to 16:00 Clock, Same day 60 min 8h 0m 7h 0m 7
07:00 to 19:00 Clock, Same day 60 min 12h 0m 11h 0m 11
00:00 to 00:00 Clock, Next day 0 min 24h 0m 24h 0m 24

One-Click Presets

Three presets load exact scenarios so you can verify the logic:

Preset Setup Gross Break Net Decimal hours Total minutes
Day with lunch Clock, 09:00 to 17:30, Same day, 30 min 8h 30m 0s (30,600 s) 0h 30m 0s (1,800 s) 8h 0m 0s (28,800 s) 8 480
Overnight Clock, 22:00 to 06:00, Next day, 30 min 8h 0m 0s (28,800 s) 0h 30m 0s (1,800 s) 7h 30m 0s (27,000 s) 7.5 450
Leap-day interval Dates & times, 2024-02-28 00:00 to 2024-03-01 00:00, 0 min 48h 0m 0s (172,800 s) 0h 0m 0s 48h 0m 0s (172,800 s) 48 2880

Visual Bar, Clipboard Export, and Print

A reactive SVG bar shows net elapsed time in orange against the deducted break in slate. The break is drawn at the tail end purely for proportional comparison; its position is illustrative and not chronological. The graphic supports zoom, pan, and viewport reset.

The clipboard export produces a plain-text summary with the timestamps, gross, break, and net values, decimal hours, total minutes and seconds, the wall-clock assumptions, and the canonical URL. The print and PDF action expands every collapsed section before the browser's print dialog opens.

Scope Boundaries: What This Tool Does Not Model

Knowing the limits matters as much as the formulas.

  • Wall-clock only. Every calendar day is exactly 86,400 seconds.
  • No time zones or daylight saving. Browser datetime-local inputs, documented on MDN Web Docs, carry no offset. A 23-hour spring-forward day or a 25-hour fall-back day is not detected, so an interval crossing a transition can be off by one hour compared with real elapsed time.
  • No leap seconds. Time units follow the SI definitions in NIST Special Publication 811, and no leap seconds are inserted.
  • Elapsed, not inclusive. The result is T2−T1T_2 - T_1. January 1 to January 2 at the same time is 24 hours, not "2 days".
  • No months-and-years breakdown. Month lengths vary from 28 to 31 days, so "X months, Y days" is ambiguous and deliberately omitted.
  • No payroll compliance. Daily or weekly overtime thresholds, spread-of-hours rules, and tax deductions are outside scope. Treat the net hours as an input to a payroll system, not as a compliance determination.

Frequently Asked Questions

How do I convert 7 hours 45 minutes to decimal hours?

Convert the minutes to hours and add: 7+45/60=7.757 + 45/60 = 7.75. Enter the interval or its endpoints and the decimal hours field reports the same value.

Why does my result show more than 24 hours?

The breakdown is not capped at a day. A 48-hour interval is reported as 48h 0m 0s, which makes it easy to total multi-day durations directly.

Can I calculate the time between two dates without clock times?

Yes. Switch to Dates & times, set both times to 00:00, and the result is the day gap multiplied by 24 hours.

Calculation Methodology Documented

Read the formula definitions, supported input ranges, and limitations before using this estimate.

Review Methodology
Debjeet Bhowmick
Author Debjeet Bhowmick AWS Certified Solutions Architect • Cloud & DevOps Consultant

AWS Certified Solutions Architect Professional and Senior Cloud & DevOps Consultant with over 14 years of hands-on expertise architecting resilient cloud infrastructure across AWS, GCP, and Azure. Specializes in infrastructure as code, continuous delivery automation, and telemetry across Terraform, Ansible, Docker, Kubernetes, ELK, Python, and SQL. Creator of OrangeCalc, delivering client-side high-precision computational tools.