RFC 2822 Date Format
Learn the RFC 2822 date format used in email headers and HTTP. Understand the syntax, timezone abbreviations, and how to parse and generate it.
Format
Mon, 15 Jan 2024 09:30:00 +0000
Detailed Explanation
RFC 2822 defines the date and time format originally specified for email message headers. Its format is human-readable and includes the day of the week: ddd, DD MMM YYYY HH:mm:ss ±HHMM. You encounter it in email Date: headers, some HTTP headers, and RSS feeds.
Format breakdown:
Mon, 15 Jan 2024 09:30:00 +0000
│ │ │ │ │ │
│ │ │ │ │ └── Timezone offset (no colon)
│ │ │ │ └── Time (24-hour)
│ │ │ └── Year (4-digit)
│ │ └── Month (3-letter abbreviation)
│ └── Day of month
└── Day of week (3-letter abbreviation)
Key differences from ISO 8601:
| Feature | ISO 8601 | RFC 2822 |
|---|---|---|
| Month format | Numeric (01-12) | Abbreviated name (Jan-Dec) |
| Day of week | Not included | Included (optional) |
| Separator | T between date/time | Space between date/time |
| Timezone | Z or ±HH:MM | ±HHMM (no colon) |
| Sortable | Yes | No (month names break sorting) |
Generating RFC 2822 in code:
// JavaScript
new Date().toUTCString()
// "Mon, 15 Jan 2024 09:30:00 GMT"
# Python
from email.utils import formatdate
formatdate(timeval=None, localtime=False, usegmt=True)
Common pitfalls:
Legacy systems sometimes use timezone abbreviations like "EST" or "PST" instead of numeric offsets. These abbreviations are ambiguous (CST can mean Central Standard Time in the US, China Standard Time, or Cuba Standard Time) and should be avoided. Always use the numeric offset format +0000 for unambiguous parsing.
When to use which: Prefer ISO 8601 for APIs and data storage. Use RFC 2822 when required by a protocol specification (SMTP, certain HTTP headers, RSS). If you have a choice, ISO 8601 is the better default because it sorts naturally and is less ambiguous.
Use Case
When building an email-sending service, you must format the Date header in RFC 2822 format, or email clients may flag the message as suspicious or display the wrong send time.