12-Hour vs 24-Hour Time Format

Understand the differences between 12-hour (AM/PM) and 24-hour (military) time formats. Learn which countries use which system and how to convert between them in code.

Concepts

Detailed Explanation

12-Hour vs 24-Hour Clock

The world is roughly split between two time notation systems. Understanding both is essential for building globally usable software.

24-Hour Format (Military Time)

00:00 — Midnight
06:30 — 6:30 in the morning
12:00 — Noon
13:00 — 1:00 PM
18:45 — 6:45 PM
23:59 — One minute before midnight

Hours range from 00 to 23. There is no AM/PM designator. This format is unambiguous and preferred for technical contexts.

12-Hour Format

12:00 AM — Midnight
 6:30 AM — Morning
12:00 PM — Noon
 1:00 PM — Afternoon
 6:45 PM — Evening
11:59 PM — One minute before midnight

Hours range from 12, 1, 2, ... 11 with AM/PM suffix. Note the confusing edge cases: 12:00 AM is midnight (start of day) and 12:00 PM is noon.

Regional Usage

24-hour format is standard in most of the world:

  • Europe, Asia, Africa, Latin America
  • Military, aviation, medical, and scientific fields
  • Most computing and logging systems

12-hour format is common in:

  • United States, Canada, Australia
  • Philippines, India (informal)
  • Most English-speaking countries (informal usage)

Format Tokens Across Languages

Language 24-hour 12-hour AM/PM
JavaScript (date-fns) HH:mm hh:mm a a
Python %H:%M %I:%M %p %p
Java HH:mm hh:mm a a
PHP H:i h:i A A/a
Go 15:04 3:04 PM PM
C# HH:mm hh:mm tt tt

Conversion Logic

24h to 12h:
  0  → 12 AM     12 → 12 PM
  1  → 1 AM      13 → 1 PM
  11 → 11 AM     23 → 11 PM

12h to 24h:
  12 AM → 0      12 PM → 12
  1 AM  → 1      1 PM  → 13
  11 AM → 11     11 PM → 23

Use Case

Choosing between 12-hour and 24-hour format matters for user-facing date displays in international applications, scheduling interfaces, flight booking systems, hospital record systems, and any software deployed globally. Locale-aware formatting (Intl.DateTimeFormat) can automatically select the appropriate format.

Try It — Date Format Reference & Tester

Open full tool