Regular Expression: ISO8601 Date Time Format

The ISO 8601 specification allows a wide variety of date time formats. Here are two versions of the RegExp for ISO8601 date time format. This first checks if the string is a valid ISO 8601 date string. The other one for a full date string including the hours/minutes/seconds (Commonly used in API’s).

They can be used to check string contains an ISO 8601 date string or validate the date time string after converted from the Date object.


Leave a Reply

Your email address will not be published. Required fields are marked *