validation
Time (24-hour HH:MM) Regex Pattern
Validates 24-hour time in HH:MM format. Hours 00-23, minutes 00-59. Does not include seconds — for HH:MM:SS just append <code>:[0-5]\d</code>.
/^([01]\d|2[0-3]):[0-5]\d$/ What each part matches
^([01]\d|2[0-3]) — hours: 00-19 OR 20-23: — literal colon[0-5]\d$ — minutes: 00-59✓ These match
- 00:00
- 13:45
- 23:59
✗ These don't
- 24:00
- 12:60
- 9:30
- 13:45:00
Use in your code
JavaScript
const re = /^([01]\d|2[0-3]):[0-5]\d$/;
re.test(input); // → true or false Python
import re
re.fullmatch(r"^([01]\d|2[0-3]):[0-5]\d$", input) PHP (PCRE)
preg_match('/^([01]\d|2[0-3]):[0-5]\d$/', $input); Go
re := regexp.MustCompile(`^([01]\d|2[0-3]):[0-5]\d$`)
re.MatchString(input) FAQ
Does this time (24-hour hh:mm) regex work in JavaScript?
Yes. Every pattern in the Utilko regex library is tested to work in JavaScript RegExp, PCRE (PHP, Nginx), and Python `re`. Where flavor matters (lookbehind, named groups), the pattern page flags it.
How do I use this pattern?
Copy the pattern from the code block above. In JavaScript:
new RegExp('^([01]\d|2[0-3]):[0-5]\d$') or literal /^([01]\d|2[0-3]):[0-5]\d$/. Or click "Try in regex tester" to open it pre-loaded in Utilko's browser-based regex tester.Should I use this for security-critical validation?
Client-side regex is fine for UX (immediate feedback on a form). For anything security-critical — payments, auth, data integrity — always re-validate server-side using the same pattern PLUS domain-specific checks (Luhn checksum for cards, actual email delivery test, DNS resolution for domains).