Beginner

12-Hour to 24-Hour Time Converter

Convert any time between the 12-hour AM/PM clock and the 24-hour (military) format, and see the exact seconds since midnight.

Conversion direction

AM or PM

24-hour time
09:30
Seconds since midnight
34,200s

Total seconds elapsed since 00:00

24-hour format
09:30
12-hour format
9:30 AM
Minutes since midnight
570
Clock position for the entered time
Step by step
  1. 1

    24-hour hour

    (9 mod 12) + 0 = 9
    mod 12 maps 12 → 0; then add 12 for PM.
  2. 2

    Seconds from hours

    9 × 3,600 = 32,400
  3. 3

    Seconds from minutes

    30 × 60 = 1,800
  4. 4

    Seconds since midnight

    32,400 + 1,800 = 34,200
Results are estimates for general information only and are not professional advice — always verify important results independently before relying on them. Read the full disclaimer.
Quick answer

How does this calculator work?

To convert 12-hour to 24-hour time, take the hour mod 12 and add 12 if it is PM, keeping minutes the same and zero-padding to two digits. Reverse the process for 24-hour to 12-hour. This tool also reports the exact seconds since midnight for any entered time.

Formula
H24 = (hour mod 12) + (PM ? 12 : 0); h12 = ((H24 + 11) mod 12) + 1
How this is calculated

Choose a conversion direction. For 12-hour to 24-hour, enter the hour (1-12), the minute (0-59), and whether the time is AM or PM. The 24-hour hour is computed as (hour mod 12) plus 12 when the period is PM, so 12 AM becomes 00 and 12 PM stays 12. The result is zero-padded to two digits (for example 9:30 AM becomes 09:30).

For 24-hour to 12-hour, enter the hour (0-23) and minute. The period is AM when the hour is below 12, otherwise PM. The displayed 12-hour value is ((hour + 11) mod 12) + 1, which maps 0 to 12 AM and 13 to 1 PM. Both formats are shown side by side.

Seconds since midnight is H24 * 3600 + minute * 60, a useful canonical value for sorting or scheduling. Inputs outside their valid ranges (hour or minute) return no result, and fractional entries are floored to whole units. The converter ignores seconds in the input and assumes a standard 24-hour day.

Frequently asked questions

12 AM is midnight, written as 00:00. 12 PM is noon, written as 12:00.

Add 12 to the hour for any PM time except 12 PM. So 3 PM becomes 15:00 and 11 PM becomes 23:00.

It is the total number of seconds elapsed since 00:00 that day, equal to hours times 3600 plus minutes times 60.

Also known as

12 hour to 24 hour
12h to 24h
am pm to 24 hour
military time converter
time format converter
convert 12 to 24 hour
clock format converter
am pm to military time

APA

TG we-Calculate Editorial Team. (2026). 12-Hour to 24-Hour Time Converter [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/12-hour-to-24-hour-time-converter

Chicago

TG we-Calculate Editorial Team. "12-Hour to 24-Hour Time Converter." TG we-Calculate. 2026. https://we-calculate.com/calculator/12-hour-to-24-hour-time-converter.

IEEE

TG we-Calculate Editorial Team, "12-Hour to 24-Hour Time Converter," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/12-hour-to-24-hour-time-converter

BibTeX

@misc{wecalculate_12_hour_to_24_hour_time_converter, title = {12-Hour to 24-Hour Time Converter}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/12-hour-to-24-hour-time-converter}}, year = {2026}, note = {TG we-Calculate} }

Did this calculator help you?