Guides

How to Calculate Time Duration Between Two Times

Learn how to calculate time duration between two times: the subtraction formula, elapsed and clock calculator steps, and worked daytime and overnight examples.

Miryori Editorial Team3 min read
Try the Time Duration Calculator

The time duration calculator measures the span between two moments. It accepts either two elapsed-time values or two clock times, in 12-hour or 24-hour format, and it handles intervals that run past midnight. This article covers both sections of the tool and the arithmetic behind them.

To calculate time duration, subtract the start time from the end time: duration equals end time minus start time. The calculator's elapsed-time section takes two values in hours, minutes and seconds. Its clock-time section takes an hour, minute and optional second for each of two times, in 12- or 24-hour format, and adds a full day when the end time falls earlier on the clock. The result is reported as hours, minutes and seconds.

What is the formula for time duration?

The elapsed-time section uses a direct subtraction. The clock-time section wraps the same idea in a helper that first normalizes 12-hour values, then adds a day when the end time is earlier on the clock face.

duration=end time−start time\text{duration} = \text{end time} - \text{start time}

clock duration=getClockDuration⁡(format,start,end)\text{clock duration} = \operatorname{getClockDuration}(\text{format}, \text{start}, \text{end})

The format and am/pm selectors store the following option values internally:

Setting Option Value
Clock format 12-hour 0
Clock format 24-hour 1
am/pm am 0
am/pm pm 1

How do I use the elapsed time calculator?

In the elapsed-time section, enter a start time and an end time; the duration between them appears immediately. By default the values are entered in hours, minutes and seconds, but clicking on a unit opens a dropdown so you can select other time units to suit your needs.

You may enter any two times in this section, provided the end elapsed time is greater than the start elapsed time. No 12- or 24-hour convention applies here, so the values are treated purely as elapsed quantities.

How do I use the clock time calculator?

The clock-time section works out the duration between two times in a single day, or overnight. Follow these steps:

  1. Select the 12-hour or 24-hour format.
  2. Enter the start clock time: hour, minute, and optionally second. In 12-hour mode, also choose am or pm.
  3. Enter the end clock time in the same way. Intervals that begin on one day and end on the next are supported, so you can measure from 8 pm until 5 am the following morning.
  4. Read the result as hours, minutes and seconds. Click the units to display the dropdown if you want another time unit.

For a work shift with breaks, an 8-hour shift calculator is a better fit; for a whole week of shifts, use a time card calculator.

Worked example: 8:13 am to 4:55 pm

Convert the pm time to 24-hour form first: 4 + 12 = 16, so 4:55 pm becomes 16:55. Now subtract the start time as a long subtraction:

16:55−8:138:42\begin{array}{rrrrr} 16:55\\ -8:13\\ \hline 8:42 \end{array}

The hours column gives 16 − 8 = 8 hours, and the minutes column gives 55 − 13 = 42 minutes. The duration is therefore 8 hours 42 minutes. To express those hours and minutes as one decimal value, use a time to decimal calculator.

Frequently Asked Questions

Can the calculator handle a duration that crosses midnight?

Yes. The clock-time section explicitly supports intervals that start on one day and end on the next, such as 8 pm to 5 am the next morning.

What units can I enter in the elapsed time section?

The default is hours, minutes and seconds. Clicking on a unit opens a dropdown that lets you select other time units.

Can I include seconds in a clock time?

Yes. The hour and minute fields are standard, and the second field is optional for both the start and the end time.

What if the end elapsed time is smaller than the start elapsed time?

That combination is not accepted in the elapsed-time section: the end value must be greater than the start value.

References

  • The Omni "Time Duration Calculator" source article and its FAQ.
  • The calculator's getClockDuration definition, which normalizes 12-hour values and rolls over past midnight.
  • Standard time arithmetic: 60 seconds per minute, 60 minutes per hour and 24 hours per day.
Calculator

Time Duration Calculator

Calculate Time Duration with practical date & time formulas, interactive references and step-by-step results. Free, fast and private.

Try the Time Duration Calculator