A regular expression for ISO 8601 dates

Plaintext

Matches a date, optionally with a time and a zone. Deliberately strict about separators.

^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])
(?:T([01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?
(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d))?$

More in Text Processing

Random picks