What is the correct format for RSS feed pubdate?

Viewed 83306

I'm having trouble getting the date of my RSS Feed to run correctly. Do you know what the proper date to show it is?

I have it stored in a field called creation_date in this format: 2012-08-14 10:17:12

Then i grab it:

$pubDate = $article[creation_date];

Then I convert it:

$pubDate= date("Y-m-d", strtotime($pubDate));

Then within my item tag I place it:

<pubdate>'.date("l, F d, Y", strtotime($pubDate)).'</pubdate>

Is there something that I'm not seeing?

10 Answers

The easiest method is to use the DATE_RSS predefined constant (available since PHP 5.1.0).

$pubDate = date(DATE_RSS, strtotime($pubDate));

This is how I solved to compile a valid RFC-822 datetime for RSS into XSLT:

<xsl:variable name="now" select="fn:current-dateTime()"/>
<xsl:value-of select="format-dateTime($now, '[FNn,3-3], [D01] [MNn,3-3] [Y0001] [H01]:[m01]:[s01] [Z0001]')"/>
Related