Skip to main content
Regexflux

24-Hour Time

beginner

Matches time in 24-hour format (HH:MM or HH:MM:SS).

time24hourformatvalidation

Pattern

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

Try 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

LanguageSupport
JSFull support
PYTHONFull support
JAVAFull support
PHPFull support
GOFull 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

Related Patterns