HomeRegex Library24-Hour Time (HH:mm) Regex
100% Client-Side β€’ 0 B Data Leaves Browser
formatting

24-Hour Time (HH:mm) Regex

Validates 24-hour military and European clock time from 00:00 through 23:59.

Regular Expression Pattern:
/^(?:[01]\d|2[0-3]):[0-5]\d$/
Valid Match Example:
23:59
Invalid / Non-Match Example:
24:00

Regex Syntax Breakdown & Explanation

  • β€’[01]\d|2[0-3] : Restricts hours from 00 to 23
  • β€’: : Colon separator
  • β€’[0-5]\d : Restricts minutes from 00 to 59

Implementation in Popular Languages

JavaScript / TypeScript
const regex = /^(?:[01]\d|2[0-3]):[0-5]\d$/;
const isValid = regex.test("23:59");
console.log(isValid); // true
Python (re)
import re

pattern = r"^(?:[01]\d|2[0-3]):[0-5]\d$"
match = re.match(pattern, "23:59")
print(bool(match)) # True
Go (regexp)
package main
import (
  "fmt"
  "regexp"
)

func main() {
  re := regexp.MustCompile(`^(?:[01]\d|2[0-3]):[0-5]\d$`)
  fmt.Println(re.MatchString("23:59"))
}
Frequently Asked Questions

Frequently Asked Questions

Everything you need to know regarding specifications, syntax, and security best practices.

The regular expression pattern is /^(?:[01]\d|2[0-3]):[0-5]\d$/. Validates 24-hour military and European clock time from 00:00 through 23:59.