Dates & Timesflags: g
12-Hour Time with AM/PM
Match 12-hour time formats with AM or PM suffix — e.g. 9:30 AM, 11:45:15 pm.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
(?:0?[1-9]|1[0-2]):[0-5]\d(?::[0-5]\d)?\s?[AaPp][Mm] (flags: g)Raw source: (?:0?[1-9]|1[0-2]):[0-5]\d(?::[0-5]\d)?\s?[AaPp][Mm]
How it works
Hour alternation covers 1–12 (optional leading zero), minute/second classes enforce 00–59, optional whitespace separates the AM/PM suffix. Case-insensitive AM/PM via character classes.
Examples
Input
9:30 AMMatches
9:30 AM
Input
11:45:15 pmMatches
11:45:15 pm
Input
13:00 PMNo match
—Common use cases
- •US-style time input validation
- •Chat timestamp parsing
- •Calendar event extraction
- •Human-readable log scraping
Related patterns
24-Hour Time
Dates & TimesMatch 24-hour time formats HH:MM or HH:MM:SS with valid hour (00–23) and minute/second (00–59) ranges.
ISO 8601 Date-Time
Dates & TimesMatch full ISO 8601 date-times with timezone offset or Z suffix (e.g. 2024-01-15T14:30:00Z).
European Date Format (DD/MM/YYYY)
Dates & TimesMatch European-style dates in DD/MM/YYYY format with valid day (01–31) and month (01–12) ranges.
ISO 8601 Date
Dates & TimesMatch dates in ISO 8601 format: YYYY-MM-DD with valid month (01–12) and day (01–31) ranges.