Transparent calculators with visible methods, assumptions, and limits.
Time Duration Calculator
Compute the exact elapsed time between two moments, with a breakdown into calendar years, months, days, and absolute hours, minutes, and seconds. The tool respects actual month lengths and leap years, and it renders a simple timeline visualization.
Enter valid start and end datetimes and click the button to see the breakdown.
The result shows the exact elapsed time between the two moments. Years and months reflect calendar lengths (e.g., February vs. March), while days, hours, minutes, and seconds are absolute. For legal or contractual day counts (e.g., business days), use a dedicated tool and verify against the governing document.
How the duration is computed
The calculator converts both inputs to UTC to avoid timezone ambiguity. It computes the absolute difference in milliseconds and then decomposes that into the largest possible whole calendar units (years, months) followed by the remaining absolute units (days, hours, minutes, seconds). Month lengths and leap years are respected, so a span from January 31 to February 28 is reported as 1 month minus 3 days, not 0 months and 28 days.
Assumptions: Uses the Gregorian calendar for all dates, including proleptic Gregorian for dates before 1582. Assumes no leap seconds and ignores daylight saving time shifts.
Coverage: Supports dates from 1970-01-01 to 2038-01-19 (32-bit Unix time bounds).
Exclusions: Does not compute business days, fiscal periods, or astronomical time. Not suitable for payroll, billing, or interest calculations where the day-count convention is defined by regulation or contract.
Unsafe uses: Do not rely on this for legal, financial, or safety-critical decisions without independent verification.
Worked examples
From the end of February 2020 to the end of February 2024, including the 2020 and 2024 leap days.
Result: calculating…
Same-day duration from 2:30 PM to 6:45 PM.
Result: calculating…
Common pitfalls
Ignoring timezone differences: If you enter local times without converting to a common timezone, the duration can be off by hours. Always normalize to UTC or ensure both inputs use the same timezone.
Assuming fixed month lengths: A naive 30-day month assumption can misstate durations by ±2 days. This calculator uses actual calendar lengths.
Forgetting leap seconds: Leap seconds are not modeled here. For astronomical or high-precision timing, use a specialized service that accounts for IERS bulletins.
Unusual boundary scenarios
Same moment: If start and end are identical, the result is zero across all units. Useful for testing or validating inputs.
Maximum representable range: The calculator supports dates from 1970-01-01 to 2038-01-19. For dates outside this range, use a dedicated astronomical calculator.
Duration formats and next actions
| Format | Use Case | Next Action |
|---|---|---|
| Years + Months + Days | Human-readable age or project length | Verify against calendar if exact month lengths matter |
| Total Days | Contractual day counts | Check the contract’s day-count convention (e.g., 30/360, Actual/Actual) |
| ISO 8601 Duration | Machine-readable exchange | Use PnYnMnDTnHnMnS format for interoperability |
Frequently asked questions
Why does 2020-02-28 to 2021-02-28 show as 1 year, not 365 or 366 days?
The calculator prioritizes calendar units. From 2020-02-28 to 2021-02-28 is exactly one calendar year, even though 2020 was a leap year. If you need the absolute day count, use the “Total Days” value in the results.
Can I calculate the duration between two times without dates?
Yes. Set both dates to the same value (e.g., 2026-01-01) and enter only the times. The calculator will compute the time difference and ignore the date portion.
How do I handle daylight saving time transitions?
The calculator converts inputs to UTC, so DST transitions are effectively ignored. If you need to account for local clock changes, convert both times to UTC first or use a timezone-aware library.
Why is the chart sometimes a single point?
If the duration is very short (e.g., a few seconds), the timeline may appear as a point. Adjust the inputs to see a meaningful span.
Sources and verification
RFC 3339: Date and Time on the Internet: Timestamps — Standard for datetime formatting used in the inputs.
Gregorian calendar on Wikipedia — Calendar rules implemented for date arithmetic.