Time Format Converter
Convert a clock time between 12-hour and 24-hour notation in both directions at once.
Last updated · View algorithm, constants and default inputs (JSON)
About this calculator
The 12-hour and 24-hour clocks encode the same instants, just with different conventions. The 24-hour form runs 00:00 to 23:59 and carries the whole day in the hour number; the 12-hour form pairs a number from 1 to 12 with AM or PM, and midnight and noon are the two cases that trip people up, because both read as 12 rather than 0.
Worked example
calculated with the default values below
Hours (24-hour clock) 9 · Minutes 5 · Seconds 0 24-hour format 09:05:00 · 12-hour format 09:05:00 AM · AM/PM marker AM
General background references
Disclaimer
These calculators give general date results. Public holidays, working-day conventions and time-zone rules are set locally and change, so confirm against the official calendar for anything legally or contractually binding.
Implementation source
This record describes the implementation used by this page. It is not independent validation. External references, when available, support only the stated formula or definition; estimates and custom rules retain their own assumptions.
Formula and variables
h12 = { 12, h mod 12 = 0; h mod 12, h mod 12 ≠ 0 }; p = { AM, h < 12; PM, h ≥ 12 }; t12 = h12:m:s + p
- h
- hour, 0–23
- m
- minute, 0–59
- s
- second, 0–59
- h12
- 12-hour clock hour
- p
- period marker (AM/PM)
- t12
- 12-hour time string
Inputs are floored and clamped before display, then zero-padded to two digits; AM applies before noon (h < 12), PM after.
Frequently asked questions
What do 12:00 AM and 12:00 PM mean?
By the common 12-hour clock convention, 12:00 AM is midnight at the start of a day and 12:00 PM is noon. For schedules where the date boundary matters, 00:00 and 12:00 in 24-hour notation avoid that ambiguity.