Regular Expressions 101

Community Patterns

1...56789...902

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
(?P<y>\d{4}) - (?P<m>\d{2}) (?: - (?P<d>\d{2}) )? (?: [T\s] (?P<hh>\d{2})\: (?P<mm>\d{2}) (?:\:(?P<ss>\d{2}))? (?:[+-](?P<tz>\d{2}\:\d{2}))? (?: (?:\.(?P<u>\d{2,4}))?[Z] )? )?$
/
gmixu

Description

Regex supporting all formats of ISO 8601 dates (with timezone and microseconds) that are compatible with PHP DateTime constructor and strtotime.

Submitted by mjolnic - 9 years ago