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)