Guides

How to Convert 12-Hour Time to 24-Hour Time?

Learn how to convert 12-hour time to 24-hour time: the am and pm rules, the calculator's format values, and worked conversions such as 12:30 am and 4:55 pm.

Miryori Editorial Team2 min read
Open the calculator

Timetables and flight bookings often use the 24-hour clock, while everyday conversation uses am and pm. The clock-time section of the calculator accepts both, and it converts 12-hour entries to a 24-hour day running from 00:00 to 23:59 before measuring a duration.

To convert 12-hour time to 24-hour time, keep morning (am) hours as they are, except that 12 am becomes 00. For afternoon and evening (pm) hours below 12, add 12 to the hour; 12 pm stays at 12. Minutes and seconds never change. The calculator applies these rules automatically in 12-hour mode, and it stores 0 for the 12-hour option and 1 for the 24-hour option.

What are the am and pm conversion rules?

The calculator's clock helper adjusts the hour only. An am hour of 12 is reset to 0, and a pm hour below 12 has 12 added to it; every other hour is left alone.

24-hour hour={hour+12pm hour below 120am hour equal to 12hourotherwise\text{24-hour hour} = \begin{cases} \text{hour} + 12 & \text{pm hour below 12} \\ 0 & \text{am hour equal to 12} \\ \text{hour} & \text{otherwise} \end{cases}

Which format values does the calculator use?

The format selector and the am/pm selector each have two options with these stored values:

Selector Option Stored value
Clock format 12-hour 0
Clock format 24-hour 1
am/pm am 0
am/pm pm 1

Worked example: 12:30 am and 4:55 pm

For 12:30 am, the hour is 12 in the morning, so it resets to 00; the minutes are unchanged. That gives 00:30, which the source describes as the first 30 minutes of the day.

For 4:55 pm, the hour is a pm hour below 12, so add 12: 4 + 12 = 16. The minutes stay at 55, giving 16:55. These are the same conversions used when measuring a duration that starts at 8:13 am and ends at 4:55 pm.

Frequently Asked Questions

When does the am/pm selector appear?

Only in 12-hour mode. In 24-hour mode the hour already carries the full day value, so no am/pm choice is shown.

Why might I choose the 24-hour format?

The source notes that the 24-hour format is the one you might encounter when booking a flight, so it is useful when your input times come from a timetable in that format.

Can I enter an hour above 12 in 12-hour mode?

No. The calculator suppresses the clock duration output when the clock format is 12-hour and either the start or end hour is greater than 12; use 24-hour mode for such values.

References

  • The Omni "Time Duration Calculator" FAQ, "What is 12:30 am in 24-hour format?".
  • The calculator's getClockDuration definition for the am, pm and 12 o'clock rules.
  • The calculator's clock-time input conditions for 12-hour versus 24-hour mode.
Calculator

Time Duration Calculator

Calculate Time Duration with practical date & time formulas, interactive references and step-by-step results. Free, fast and private.

Open the calculator