Time Duration Calculator
Calculate the exact hours, minutes, and seconds passed between two times.
How to Use
Enter your start time
Input the start time using hours and minutes in 24-hour or 12-hour format.
Enter your end time
Input the end time — if it's before the start time, an overnight span is automatically calculated.
Read the duration breakdown
See the result in hours:minutes:seconds format, total minutes, and decimal hours.
Use decimal hours for billing
Copy the decimal hours value directly into payroll or invoicing software.
Elapsed Time Calculations: Sexagesimal Math, Midnight Transitions, and Payroll Standards
Calculating the exact duration between a start time and an end time is essential for tracking employee work hours, billing legal clients, logging flight hours, and analyzing manufacturing cycles. While time of day is tracked on a 12-hour or 24-hour cycle, converting intervals into billable decimal hours requires sexagesimal (base-60) arithmetic.
The Midnight Rollover Algorithm (Modulo 24 Math)
The most common complication in elapsed time calculation occurs during overnight shifts that cross midnight (e.g., beginning at 10:30 PM and ending at 6:45 AM the following morning). In standard arithmetic, subtracting 22:30 from 06:45 yields a negative duration (-15 hours and 45 minutes).
Our calculation engine resolves midnight transitions using modulo-24 normalized math:
// Handling overnight shifts across midnight:
let durationMinutes = (endHour * 60 + endMin) - (startHour * 60 + startMin);
if (durationMinutes < 0) {
durationMinutes += 24 * 60; // Add 1,440 minutes (24 hours) for overnight transition
}
const elapsedHours = Math.floor(durationMinutes / 60);
const elapsedMinutes = durationMinutes % 60;
Decimal Hours vs. Sexagesimal Hours for Payroll
Payroll systems, corporate ERPs, and accounting platforms cannot process sexagesimal minutes (e.g., 7 hours and 45 minutes) directly into currency multiplication formulas (HourlyRate × Hours). Minutes must be converted into decimal hours:
| Clock Minutes | Decimal Equivalent (Exact) | 15-Minute Payroll Rounding | 6-Minute Legal Increment (0.1 hr) |
|---|---|---|---|
| 6 Minutes | 0.10 hr | 0.00 hr | 0.10 hr (1 Tenth) |
| 15 Minutes | 0.25 hr | 0.25 hr (Quarter) | 0.20 or 0.30 hr |
| 30 Minutes | 0.50 hr | 0.50 hr (Half) | 0.50 hr (5 Tenths) |
| 45 Minutes | 0.75 hr | 0.75 hr (Three Quarters) | 0.70 or 0.80 hr |
| 54 Minutes | 0.90 hr | 1.00 hr | 0.90 hr (9 Tenths) |
Real-World Examples & Use Cases
Employee Timesheets and Payroll
Calculating work hours for hourly employees requires precise time arithmetic. Shifts starting at 8:45 AM and ending at 5:20 PM yield 8 hours 35 minutes = 8.583 decimal hours. Payroll software that accepts decimal hours needs this conversion. Night shift workers clocking in at 10 PM and out at 6:30 AM have an 8.5-hour shift that crosses midnight — a calculation that simple subtraction gets wrong. A time duration calculator handles both standard and overnight shifts correctly.
Freelancer Billing and Project Time Tracking
Consultants and freelancers billing by the hour need accurate duration calculations for client invoices. A meeting from 2:15 PM to 3:50 PM is 1 hour 35 minutes = 1.583 hours. At $150/hour, that's $237.50. Tracking multiple work sessions across a day (9:00–11:30, 1:15–3:45, 4:30–5:00) requires adding individual durations accurately. Time duration calculation helps freelancers build precise time logs that justify billing amounts.
Sports and Fitness Timing
Athletes and coaches track elapsed times for performance analysis. A running session from 6:15 AM to 7:42 AM is 1 hour 27 minutes. Comparing this week's total training hours against last week requires accurate duration arithmetic. Swim splits, cycling segments, and interval training blocks each have specific durations that must be summed for total training volume. Race timing, heat durations, and rest interval tracking all depend on time duration calculations.
Shipping, Transit, and Travel Time
Logistics professionals and travelers need to calculate transit durations. A flight departing at 23:30 (11:30 PM) and landing at 07:15 (7:15 AM) the next day has a duration of 7 hours 45 minutes — an overnight calculation. Trucking dispatch needs to know how many hours a driver has been on the road since their last break for Hours of Service compliance. Package transit time SLAs measured in hours require accurate duration calculation from pickup to delivery timestamps.
How It Works
Time Duration Formula: Basic calculation: duration = endTime - startTime (in total minutes or seconds) For 24-hour time: 1. Convert both times to total minutes from midnight: totalMinutes = hours × 60 + minutes 2. Subtract start from end: duration = endTotalMinutes - startTotalMinutes 3. If result is negative (overnight span): duration = duration + 1440 (add 24 hours = 1440 minutes) Convert result to hours:minutes: hours = Math.floor(duration / 60) minutes = duration % 60 Decimal hours (for billing): decimalHours = duration / 60 Example (overnight shift): Start: 22:30 → 22×60 + 30 = 1350 minutes End: 06:15 → 6×60 + 15 = 375 minutes 375 - 1350 = -975 (negative → add 1440) Duration = -975 + 1440 = 465 minutes = 7 hours 45 minutes = 7.75 decimal hours For seconds precision: Convert all times to total seconds, apply same algorithm, then convert result: hours = floor(s/3600), minutes = floor((s%3600)/60), seconds = s%60
Frequently Asked Questions
How does the calculator handle times crossing midnight?▼
What is the difference between duration in minutes and decimal hours?▼
Can I calculate durations longer than 24 hours?▼
How do I calculate total hours for a work week from daily durations?▼
How is time duration used in computing and APIs?▼
Related Tools
Explore other tools in this category.
Age Calculator
Calculate your exact age in years, months, and days based on your date of birth.
Age in Days & Hours
Find exactly how old you are in years, months, weeks, days, hours, and minutes.
Countdown Timer
Set a custom countdown with hours, minutes, and seconds. Pause, resume, and use quick presets.
Timezone Converter
Convert any date and time between world timezones. Includes a live clock mode and multi-zone comparison.
Unix Timestamp Converter
Convert Unix timestamps to human-readable dates and vice versa. Shows a live current timestamp.
Date Difference Calculator
Find the exact chronological difference in years, months, and days between two historical or future dates.