24-Hour Time
beginnerMatches time in 24-hour format (HH:MM or HH:MM:SS).
time24hourformatvalidation
Pattern
/(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?/gTry It
0 of 8 strings matched
Explanation
Matches hours 00-23, minutes 00-59, and optional seconds 00-59 separated by colons.
Test Strings
Matching
- 09:30
- 23:59:59
- 00:00:00
- 12:00
Non-matching
- 24:00
- 9:30
- noon
- 99:99
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);Common Variations
With milliseconds
(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d\.\d{3}HH:MM:SS.mmm format