UnitCompiler
⏰

Time Format & Duration Calculator

Convert 12-hour AM/PM to 24-hour military time, break down decimal hours into HH:MM:SS, and measure elapsed duration.

Instant 12-Hour (AM/PM) ↔ 24-Hour (Military) Converter

12-Hour Standard Clock (AM/PM)
:

Example: 2:30 PM (afternoon)

24-Hour Military Format
: HRS

Military Format:1430 hours

Natural Speech: Two thirty in the afternoon (14:30)
Midnight = 00:00 (12:00 AM) • Noon = 12:00 (12:00 PM)

Time Conversion Reference Rules

12h to 24h Military Time

Exact Formula
PM Hours = (H % 12) + 12

For PM times (except 12 PM), add 12 to the hour. For 12 AM (midnight), the 24-hour time is 00:00.

Example: 2:30 PM = 2 + 12 = 14:30 | 12:45 AM = 00:45

Decimal Hours to HMS

Exact Formula
Mins = (Dec - Hours) × 60

Multiply the decimal remainder by 60 to obtain minutes, then multiply the remaining decimal by 60 for seconds.

Example: 2.5 hrs = 2 hrs + (0.5 * 60) = 2 hrs 30 mins

Seconds to HH:MM:SS

Exact Formula
H = ⌊S/3600⌋, M = ⌊(S%3600)/60⌋

Divide total seconds by 3600 to find full hours, and take the modulo remainder for minutes and seconds.

Example: 3661 s = 1 hr (3600s), 1 min (60s), 1 sec (1s)

How This Calculation Works

A time format and duration calculator converts between 12-hour AM/PM clocks and 24-hour military notation, splits decimal hours (such as timesheet entries like 2.75 h) into hours, minutes, and seconds (HH:MM:SS), and computes exact elapsed durations across midnight or shift schedules.

Core Formulas & Identities

12h ↔ 24h Military Rules
12:00 AM = 00:00 | PM hours (1–11) → add 12 (2:30 PM = 14:30)
Decimal Hours to HMS
Minutes = fractional(Hours) × 60 | 1 hr = 3,600 s
Elapsed Duration
Duration = (End ≥ Start) ? End − Start : (24:00 − Start) + End

Variable Legend:Use base-60 sexagesimal conversion (60 min/hr, 60 sec/min) when translating fractional hours for payroll timesheets.

Step-by-Step Worked Examples

Example1

Convert 2.5 Decimal Hours into HH:MM:SS

  1. Take whole integer part: 2 hours.
  2. Multiply fractional remainder by 60: 0.5 × 60 = 30 minutes.
  3. Total minutes = 150 min; seconds = 9,000 s.
Result:02:30:00 (150 minutes)
Example2

Convert 3,661 Seconds to Hours, Minutes, Seconds

  1. Divide by 3,600: floor(3661 / 3600) = 1 hour (remainder 61 s).
  2. Divide remainder by 60: floor(61 / 60) = 1 minute.
  3. Remaining seconds = 1 s.
Result:01:01:01 (1h 1m 1s)

Practical Applications & Accuracy Tips

  • Notice 0.30 hours equals 18 minutes, NOT 30 minutes (0.30 × 60 = 18).
  • In 24-hour format, midnight is written 00:00 and noon is 12:00 with zero AM/PM ambiguity.
  • For overnight work shifts starting at 22:00 and ending at 06:30, elapsed time wraps cleanly across 24:00 (8h 30m).