Regular Expressions 101

Forecast.io API's required ISO 8601 datetime

Open Workspace
  • PCRE (Legacy)
  • Match
1

Regular Expression

/
^(\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