Skip to main content
CalcHive

Regex for Time (HH:MM, 24-hour)

Matches time in 24-hour format (00:00 to 23:59).

Pattern

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

Pattern Breakdown

TokenExplanation
^Start of string
([01]\d|2[0-3])Hours: 00-23
:Colon separator
([0-5]\d)Minutes: 00-59
$End of string

Test Examples

InputMatch?
09:30Match
23:59Match
00:00Match
24:00No match
9:30No match

Common Use Cases

  • Time input validation
  • Schedule parsing
  • Time tracking forms

Variations

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

With seconds (HH:MM:SS)

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

12-hour format with AM/PM

Want to test this pattern with your own data?

Open the Regex Tester