Skip to main content
ilovecalcs logoilovecalcs.

Other · Live

Time arithmetic, three modes.

Add or subtract durations in days, hours, minutes, and seconds; measure the time between two clock times — even across midnight; or convert any time unit into every other. Integer-second math, no floating-point drift.

How it worksReal-time

Inputs

Pick a mode

Sum any number of D / H / M / S durations.

#1
#2
Net result
2h 15m
Total seconds
8,100

Net duration

2 of 2 rows

2h 15m

Sum of every row, normalized into days, hours, minutes, and seconds.

HH : MM : SS

02:15:00

Days
0
Hours
2
Minutes
15
Seconds
0
Total seconds
8,100
Sum across every row
Total minutes
135
To 2 decimal places
Total hours
2.25
To 4 decimal places

Field guide

How to do time math without losing seconds.

Time arithmetic is one of those tasks that looks simple — until you try it on paper. Adding 1h 45m to 2h 30m gives 4h 15m, not 3h 75m. Going from 22:30 to 06:15 means crossing midnight. And converting between seconds, minutes, hours, days, and weeks turns into ratio gymnastics fast. This calculator handles all three by reducing every value to integer seconds, doing the math there, and normalizing the result back into a clean D / H / M / S tuple — no floating-point drift, no silent off-by-one errors, no “3h 75m” outputs.

Mode 1: Adding and subtracting durations

Stack any number of D / H / M / S rows, set each one to + or , and the calculator sums them. The math is just:

netSeconds = Σ ( signi × ( d×86,400 + h×3,600 + m×60 + s ) )

The result is then normalized back into days, hours, minutes, and seconds, so 1h 45m + 2h 30m cleanly becomes 4h 15m, not the unreduced 3h 75m. If your subtractions exceed your additions, the result is shown with a leading so you don't mistake a deficit for a positive total.

Mode 2: Time between two clock times

Pick a start and an end clock time and you get the elapsed duration. Both are converted to seconds-since-midnight and subtracted:

diff = endSeconds − startSeconds
if diff < 0: diff += 86,400 // crossed midnight

That single conditional is what makes the cross-midnight case work without special-casing dates of the week. A shift from 22:30 to 06:15 isn't negative, the calculator rolls the end time forward by one full day (86,400 seconds), giving the correct 7h 45m. The optional extra days field lets you span multiple full days if you need to.

Mode 3: Converting time units

Every time unit is just a multiple of seconds. The calculator pivots through seconds, then divides into every other unit:

  • 1 minute = 60 seconds
  • 1 hour = 3,600 seconds
  • 1 day = 86,400 seconds
  • 1 week = 604,800 seconds

So 2.5 hours = 9,000 seconds = 150 minutes = 0.1042 days = 0.0149 weeks. The conversion uses real division, not lookup tables, so any input — fractional included — produces an exact result rather than a rounded estimate.

Decimal hours vs. HH:MM:SS

Payroll and timesheet software almost universally expect decimal hours: 7 hours 30 minutes is 7.50, not 7:30. Conversion is just decimalHours = totalSeconds ÷ 3,600. The hero readout above shows both formats simultaneously — copy whichever your downstream system asks for. A few common conversions to memorize:

  • 15 minutes = 0.25 hours
  • 20 minutes = 0.33 hours
  • 30 minutes = 0.50 hours
  • 45 minutes = 0.75 hours

Why integer seconds matter

Naive implementations convert minutes to fractional hours and accumulate floating-point error. Add “0.1 + 0.2” in JavaScript and you get 0.30000000000000004 — and that's exactly what happens when a payroll script adds up 7-minute breaks across a week. Working in integer seconds avoids the entire class of problem: the math is exact, the output is exact, and rounding only happens at display time.

Worked example: chained durations

Suppose you're estimating a multi-leg flight: a 2h 55m hop, plus a 1h 20m layover, plus a 7h 40m red-eye, plus a 45m ground transfer. Stacking them in the calculator gives:

(2h 55m) + (1h 20m) + (7h 40m) + (0h 45m)
= 12h 40m total · 760 minutes · 12.67 decimal hours

Worked example: overnight shift

A bartender clocks in at 20:30 and out at 03:45. The calculator detects that 03:45 < 20:30, rolls the end forward 24 hours, and reports 7h 15m: the correct shift length, with a small “crosses midnight” note so the user knows the math handled it.

Disclaimer

This is a planning and estimation tool. For payroll-grade time arithmetic that includes paid breaks, FLSA overtime, and weekly thresholds, use the Hours Calculator. For calendar arithmetic across days, weeks, months, and years, use the Date Calculator.