Time (HH:MM 24-hour)
Match times in 24-hour HH:MM format with valid hour and minute ranges.
What Is This?
This regex pattern validates time strings in 24-hour HH:MM format. Hours range from 00 to 23 (validated via (?:[01]\d|2[0-3])) and minutes range from 00 to 59 (validated via [0-5]\d). The colon is required as the separator.
How to Use
The Pattern
Use this pattern for time input validation in forms, scheduling applications, and log parsers. For 12-hour time with AM/PM, a different pattern is needed. The 24-hour format avoids AM/PM ambiguity and is the international standard for time representation.
/^(?:[01]\d|2[0-3]):[0-5]\d$/
Examples
Valid times
Matches: 00:00 12:30 23:59 08:05 14:00 Does not match: 24:00 12:60 12:00 AM 12-30 2:00
Edge cases
Matches: 00:01 09:09 22:22 Does not match: 25:00 00:99 abc:def 12:00:00
Related Entries
More from this reference:
Email Address Validation
Validate email addresses with a standard pattern covering most common formats.
URL Pattern
Match HTTP and HTTPS URLs with optional port, path, query string, and fragment.
Phone Number (US/International)
Match US and international phone numbers with optional country code and separators.
Date (YYYY-MM-DD)
Match dates in ISO 8601 YYYY-MM-DD format with basic month and day validation.
Credit Card Number (Generic)
Match generic credit card numbers in grouped or continuous 16-digit format.
UUID v4
Match UUID v4 identifiers with the standard 8-4-4-4-12 hex format and version check.
Base64 Encoded String
Match standard Base64 encoded strings with optional padding.
Frequently Asked Questions
How do I add optional seconds (HH:MM:SS)?
Extend the pattern to: ^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d$. For ISO 8601 duration formats, combine with date patterns for full datetime validation.
Should I store times in 24-hour or 12-hour format?
Store times in 24-hour format (HH:MM or HH:MM:SS) internally and convert to 12-hour with AM/PM for display only. 24-hour format avoids ambiguity and sorts correctly.