Dates & Timesflags: g

24-Hour Time

Match 24-hour time formats HH:MM or HH:MM:SS with valid hour (00–23) and minute/second (00–59) ranges.

Try it in RegexPro

Pattern

regexJavaScript
/(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?/g

Raw source: (?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?

How it works

Hour alternation enforces 00–23, minute/second classes enforce 00–59. The optional :SS group makes seconds optional.

Examples

Input

14:30

Matches

  • 14:30

Input

23:59:59

Matches

  • 23:59:59

Input

25:00

No match

Common use cases

  • Log timestamp extraction
  • Scheduling input validation
  • Transit/flight time parsing
  • Analytics time-bucket aggregation