RFC 2822 Date Format Regular Expression

A regular expression to match RFC 2822 timestamps.

/^(?:(Sun|Mon|Tue|Wed|Thu|Fri|Sat),\s+)?(0[1-9]|[1-2]?[0-9]|3[01])\s+(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+(19[0-9]{2}|[2-9][0-9]{3})\s+(2[0-3]|[0-1][0-9]):([0-5][0-9])(?::(60|[0-5][0-9]))?\s+([-\+][0-9]{2}[0-5][0-9]|(?:UT|GMT|(?:E|C|M|P)(?:ST|DT)|[A-IK-Z]))(\s+|\(([^\(\)]+|\\\(|\\\))*\))*$/

Matches:

  • Thu, 30 Dec 2020 20:21:46 -0800
  • Thu, 30 Dec 2020 20:21:46 +0200

Non-matches:

  • Thu, Dec 30 2020 20:21:46 -0800
  • 2020-12-30 17:21:59

See Also: