Skip to content

12-Hour Time with AM/PM

Type Registry

12-Hour Time with AM/PM

datetime.time.hms_12h

12-hour time with AM/PM indicator. Standard in US and some Commonwealth countries.

Domain datetimetime
Casts to TIME
Scope Universal

Try it

CLI
$ finetype infer -i "10:30:00 AM"
→ datetime.time.hms_12h

DuckDB

Detect
SELECT finetype('10:30:00 AM');
-- → 'datetime.time.hms_12h'
Cast expression
strptime({col}, '%I:%M:%S %p')::TIME
Format: %I:%M:%S %p
Safe cast pipeline
-- Normalise and cast in one step
SELECT TRY_CAST(finetype_cast(my_column) AS TIME) AS clean_value
FROM my_table
WHERE finetype(my_column) = 'datetime.time.hms_12h';

JSON Schema

finetype schema datetime.time.hms_12h
{
  "$id": "https://noon.sh/schemas/datetime.time.hms_12h",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "12-hour time with AM/PM indicator. Standard in US and some Commonwealth countries.",
  "examples": [
    "10: 30: 00 AM",
    "11: 59: 59 PM",
    "12: 00: 00 AM"
  ],
  "maxLength": 11,
  "minLength": 11,
  "pattern": "^\\d{2}:\\d{2}:\\d{2} [AP]M$",
  "title": "12-Hour Time with AM/PM",
  "type": "string"
}

Examples

10:30:00 AM11:59:59 PM12:00:00 AM

Types in datetime