Regular Expressions 101

ISO 8601 datetime for Forecast.io API

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 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