Time Calculator
Find the exact duration between two times, or add and subtract hours and minutes from any starting time, including across midnight.
Formula verified July 2026
Duration
—
How this time calculator works
Switch between two modes: find the duration between two times of day, or add/subtract a number of hours and minutes from a starting time. Both handle the wraparound past midnight automatically.
How time duration is calculated
Convert both times to minutes since midnight, subtract the start from the end, and if the result is negative (the end time is on the next day), add 24 hours (1,440 minutes) before converting back to hours and minutes.
Step-by-step: duration between two times
- Convert the start time to total minutes since midnight (hours × 60 + minutes).
- Do the same for the end time.
- Subtract start from end. If negative, add 1,440 minutes (24 hours).
- Convert the result back to hours and minutes.
Worked example
A work shift from 9:00 AM to 5:30 PM:
- 9:00 AM = 540 minutes since midnight
- 5:30 PM = 1,050 minutes since midnight
- Duration: 1,050 − 540 = 510 minutes = 8 hours 30 minutes
For an overnight example, a shift from 10:00 PM to 6:00 AM: 6:00 AM (360 minutes) minus 10:00 PM (1,320 minutes) = −960, add 1,440 = 480 minutes = 8 hours.
Common mistakes
- Forgetting the midnight wraparound when a shift or event crosses into the next day, producing a negative or nonsensical result.
- Mixing 12-hour and 24-hour formats without converting consistently.
- Adding hours and minutes separately without carrying over when minutes exceed 60.
Tips
- When adding time across midnight, work in total minutes first, then convert back to a 12-hour or 24-hour clock at the end.
- For payroll or billing, round consistently, typically to the nearest quarter or tenth of an hour, and apply the same rule every time.
How do I calculate hours worked for payroll?
Convert your clock-in and clock-out times to minutes since midnight, subtract to find total minutes worked, then divide by 60 to get hours, adding 1,440 minutes first if the shift crosses midnight.
How do I add hours and minutes to a time that crosses midnight?
Convert the starting time to total minutes, add your duration in minutes, then take the result modulo 1,440 (the number of minutes in a day) to wrap correctly into the next day.
Can this calculator handle 12-hour and 24-hour time formats?
Yes, enter times in whichever format your browser’s time input uses, the underlying calculation works the same regardless of display format.