Regular Expressions 101

Community Patterns

Community Library Entry

-1

Regular Expression
PCRE (PHP <7.3)

/
^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(Z|[\+-]\d{2}:?\d{2})?$
/
gm

Description

Should match ISO 8601 datetime for Forecast.io API: [YYYY]-[MM]-[DD]T[HH]:[MM]:[SS] with an optional time zone formatted as Z for GMT time or {+,-}[HH][MM] (with or without separating colon) for an offset

Submitted by Clifford Paulick - 9 years ago