Regular Expressions 101

Community Patterns

Time - Hour Minute (H:i) -> 00:00 - 23:59

0

Regular Expression
PCRE (PHP <7.3)

~
^(?:2[0-3]|[01]\d|\d):[0-5]\d$
~
gm

Description

This matches times that fall within the normal range of times 00:00 - 23:59. It also allows for no leading zero for times like 6:24.

Submitted by quixrick - 7 years ago