# 12-Hour Time (HH:MM AM/PM)

Key: `datetime.time.hm_12h`

Hours and minutes with AM/PM, no seconds. Common in US scheduling applications and user interfaces.

Page: <https://meridian.online/docs/projects/finetype/types/datetime/time/hm_12h>

Format: `%I:%M %p`

Samples: `10:30 AM`, `11:59 PM`

## Background

### Origin

The 12-hour clock divides the 24 hours of the day into two periods, a.m. and p.m.[[1]](https://en.wikipedia.org/wiki/12-hour_clock) The abbreviation a.m. comes from the Latin ante meridiem, meaning before midday, and p.m. from post meridiem, meaning after midday.[[1]](https://en.wikipedia.org/wiki/12-hour_clock) The 12-hour clock can be traced back as far as Mesopotamia and ancient Egypt.[[1]](https://en.wikipedia.org/wiki/12-hour_clock) Egyptian clocks dating to around 1500 BC divided their times of use into 12 hours each.[[1]](https://en.wikipedia.org/wiki/12-hour_clock) The 12-hour clock reached its modern form in the 16th century.[[1]](https://en.wikipedia.org/wiki/12-hour_clock)

Style guides variously write the abbreviations in small capitals, as uppercase AM and PM without periods, as uppercase letters with periods, or in lowercase.[[1]](https://en.wikipedia.org/wiki/12-hour_clock) The form this type describes, a two-digit hour, a colon, two-digit minutes, a space and an uppercase AM or PM, reads more like software output than the a.m. of printed prose. (Meridian's view)

### Use

In Python's datetime module, %p is the locale's equivalent of either AM or PM, such as AM and PM for en\_US but am and pm for de\_DE.[[2]](https://docs.python.org/3/library/datetime.html) Python's documentation notes that, with strptime, the %p directive only affects the parsed hour if the %I directive is used to parse the hour.[[2]](https://docs.python.org/3/library/datetime.html) DuckDB's documentation shows strftime with %I:%M:%S %p producing 08:32:45 PM for 20:32:45.[[3]](https://duckdb.org/docs/current/sql/functions/dateformat.html)

Microsoft Excel's TIMEVALUE function accepts a time text in any of Excel's time formats, giving 6:45 PM as an example.[[4]](https://support.microsoft.com/en-us/office/timevalue-function-0b615c12-33d8-4431-bf3d-f3eb6d186645) Expect to meet unpadded hours such as 6:45 PM alongside padded ones, and decide whether to pad them before you validate a column against this form. (Meridian's view)

NIST's Times of Day FAQs say that 12 a.m. and 12 p.m. are ambiguous and should not be used.[[5]](https://www.nist.gov/pml/time-and-frequency-division/times-day-faqs) By convention, 12 a.m. denotes midnight and 12 p.m. denotes noon.[[1]](https://en.wikipedia.org/wiki/12-hour_clock) Some authors have used the reverse convention, with 12 a.m. meaning noon and 12 p.m. meaning midnight.[[1]](https://en.wikipedia.org/wiki/12-hour_clock) NIST suggests specifying an event as occurring on a particular day at 11:59 p.m. or 12:01 a.m.[[5]](https://www.nist.gov/pml/time-and-frequency-division/times-day-faqs) Before converting a column of these times, find out which convention the source system meant by 12:00 AM and 12:00 PM. (Meridian's view)

ISO 8601 uses the 24-hour clock system.[[6]](https://en.wikipedia.org/wiki/ISO_8601) When you convert these values, store them as a 24-hour time type and keep the original text if the noon and midnight readings are in any doubt. (Meridian's view)

## Sources

1. [12-hour clock](https://en.wikipedia.org/wiki/12-hour_clock) — secondary source
2. [datetime — Basic date and time types](https://docs.python.org/3/library/datetime.html) — documentation
3. [Date Format Functions](https://duckdb.org/docs/current/sql/functions/dateformat.html) — documentation
4. [TIMEVALUE function](https://support.microsoft.com/en-us/office/timevalue-function-0b615c12-33d8-4431-bf3d-f3eb6d186645) — documentation
5. [Times of Day FAQs](https://www.nist.gov/pml/time-and-frequency-division/times-day-faqs) — organisation
6. [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) — secondary source
