Regular Expressions 101

Community Patterns

Forecast.io API's required ISO 8601 datetime

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 one of the valid ISO 8601 datetime formats accepted by 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 - 8 years ago