I’m using RSS Graffitty to post RSS items to a facebook page.
The app told me the items were missing the publication date so I added this tag:
echo "<pubdate>".$row['Date']."</pubdate>";
$row[‘Date’] is obtained from my MySQL database and it’s a Datetime column.
How must I format it/echo it so it’s recognized by the RSS feed? Must I change the element?
Thanks
RSS 2.0 specifications on the
<pubDate>element should conform to the RFC 822 Date and Time syntax. Namely, to display it in the following format:If you error run your RSS feed through the W3C Feed Validator you’ll note these examples of valid RFC822 date-times:
If you wanted to use MySQL formatting, you’d call the column with the following use of
date_format(), adjusting the UTC modifier/marker as necessary:Or you can do it via the PHP date method with
DATE_RSSsetting the format for you:Make sure your
<pubDate>element appear within its parent<item>node.Also note that this element is case-sensitive. You must output
pubDatewith the capital D and not all lowercase (pubdate) as other elements can.