Regex for 12-hour time (with AM/PM)

Matches a 12-hour clock time such as 09:30 AM or 12:00pm.

^(0?[1-9]|1[0-2]):[0-5]\d\s?([AaPp][Mm])$

Proof it works

6/6 sample tests passed · compiles: true

SampleShould matchResult
09:30 AM yes pass
12:00pm yes pass
1:05 am yes pass
13:00 AM no pass
9:5 AM no pass
09:30 no pass

Try your own input

Related patterns