What is the correct format for RSS feed pubdate?

What is the correct format for RSS feed pubdate?

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

What is the correct format for RSS feed pubdate?

The confusion surrounding RSS pubDate formatting often stems from a mismatch between how developers store data in their applications and what XML parsers strictly require to interpret that data correctly. In your specific case, you are storing a timestamp as a MySQL DATETIME string (2012-08-14 10:17:12) and attempting to manipulate it within PHP before injecting it into the feed. While your current approach produces a readable human-friendly date inside the element, there is a critical distinction between what an RSS reader displays to a user and what the feed specification demands for parsing logic.

The core issue lies in the pubDate attribute itself. According to the RSS 2.0 specification, the pubDate value must be formatted as an RFC 822 date header. This is not merely a suggestion; it is a requirement for feed readers and aggregators that rely on standard parsing libraries. Your current code snippet:

$pubDate = date("l, F d, Y", strtotime($pubDate));

outputs something like Saturday, August 14, 2012. While this is perfectly fine for display inside the <description> or a custom element like <custom_date>, placing this human-readable string into the <pubDate> tag will break standard feed readers. Most parsers expect a format that looks like:

Sat, 14 Aug 2012 10:17:12 +0000

If you provide the formatted weekday and month names, or omit the timezone offset, many clients will fail to parse the date entirely, defaulting to "now" or ignoring the field. This is why you might be seeing inconsistent behavior across different feed readers; some are lenient enough to guess, while others strictly adhere to RFC 822 and discard unparseable dates.

To fix this, you need to ensure your PHP code outputs the raw RFC 822 string. You can achieve this using PHP's date() function with the specific format string D, d M Y H:i:s O. The O part is crucial here; it represents the timezone offset in hours and minutes (e.g., +0000 or -0500). If your application server runs on a server with a specific timezone setting, relying on date() without an explicit offset might result in a string that lacks the required + or - sign if you don't force it.

Here is how you should adjust your logic:

// Assuming $pubDate contains '2012-08-14 10:17:12'
$publishedAt = new DateTime($pubDate);

// Format strictly as RFC 822 with timezone offset
$rssPubDate = $publishedAt->format('D, d M Y H:i:s O');

// Output inside the item tag
echo '<pubDate>' . $rssPubDate . '</pubDate>';

Using the DateTime class is generally safer than passing strings directly to strtotime() and date(), as it handles the parsing of your database string more robustly. It also makes it trivial to adjust the timezone if you need to display the date in UTC regardless of where your server is hosted.

A common pitfall involves ignoring the timezone. If you store a time like 10:17:12 without explicitly defining the timezone offset in the output, an RSS reader in New York (UTC-5) might interpret that time as being local to the user rather than absolute, or it might assume UTC if the offset is missing. Always include the offset (e.g., +0000 for UTC) to ensure global consistency.

If you are building a feed where the date format is critical for sorting or caching logic downstream, sticking to RFC 822 is non-negotiable. For custom elements like <custom_date> intended purely for display, you can freely use l, F d, Y formats without worrying about parsers. However, when dealing with the standard <pubDate>, precision and adherence to the RFC 822 specification are mandatory for your feed to be considered valid by industry-standard aggregators.

Our network