Clock Time Validator
Validate clock time strings in 12h, 24h, ISO 8601, and military formats. Detect errors, parse components, and convert between time notations.
About
Malformed time strings cause silent data corruption in scheduling systems, log analysis, and API integrations. A value like 13:72 passes naive string checks but represents no real moment. This validator parses input against 15 recognized clock-time patterns - including 24-hour (HH:MM:SS), 12-hour with AM/PM, ISO 8601 time components, and military notation - then applies range constraints: hours 0 - 23, minutes 0 - 59, seconds 0 - 59. It flags edge cases such as 12:00 AM (midnight, not noon) and 00:00 vs 24:00 boundary handling. The tool does not guess intent. It reports exactly what is wrong and why.
Limitations: this tool validates clock time only, not date-time combinations or timezone offsets (UTC+n). Fractional seconds are accepted up to 9 decimal places per ISO 8601. Pro tip: when processing user-submitted times, always normalize to 24-hour format before storage to eliminate AM/PM ambiguity.
Formulas
Validation proceeds in three stages: pattern matching, component extraction, and range checking.
Where t is the input string, P is the set of recognized regex patterns, and the range function enforces:
For 12-hour format, the hour constraint changes to 1 ≤ h ≤ 12. Conversion to 24-hour uses:
Seconds since midnight for comparison:
Where H24 = hour in 24-hour notation, m = minutes, s = seconds, S = total seconds from midnight (0 - 86399).
Reference Data
| Format Name | Pattern | Example | Hours Range | Notes |
|---|---|---|---|---|
| 24-hour (short) | HH:MM | 14:30 | 00 - 23 | Most common international format |
| 24-hour (full) | HH:MM:SS | 14:30:59 | 00 - 23 | Includes seconds |
| 24-hour (fractional) | HH:MM:SS.fff | 14:30:59.123 | 00 - 23 | Millisecond precision |
| 12-hour (short) | hh:MM AP | 2:30 PM | 1 - 12 | Leading zero optional |
| 12-hour (full) | hh:MM:SS AP | 02:30:59 AM | 1 - 12 | With seconds |
| 12-hour (dot) | hh.MM ap | 2.30 pm | 1 - 12 | Dot separator, case-insensitive |
| Military (HHMM) | HHMM | 1430 | 00 - 23 | No separator, 4 digits |
| Military (spoken) | HHMMh | 1430h | 00 - 23 | Trailing h suffix |
| ISO 8601 (basic) | THH:MM:SS | T14:30:59 | 00 - 23 | T prefix required |
| ISO 8601 (fractional) | THH:MM:SS,fff | T14:30:59,123 | 00 - 23 | Comma as decimal (ISO standard) |
| ISO 8601 (compact) | THHMMSS | T143059 | 00 - 23 | No separators |
| Dot-separated 24h | HH.MM | 14.30 | 00 - 23 | Common in some European locales |
| Dot-separated full | HH.MM.SS | 14.30.59 | 00 - 23 | Dot as separator throughout |
| Hours only | HH | 14 | 0 - 23 | Interpreted as HH:00:00 |
| 24:00 boundary | 24:00 | 24:00:00 | 24 only | ISO 8601 end-of-day. 24:01 is invalid |
| Midnight zero | 0:00 | 0:00 | 0 | Single-digit hour accepted |