Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the correct format for RSS feed pubdate?

Tags:

php

rss

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?

like image 449
Thingamajig Avatar asked Aug 16 '12 18:08

Thingamajig


People also ask

Is RSS in XML format?

RSS is a Web content syndication format. Its name is an acronym for Really Simple Syndication. RSS is a dialect of XML. All RSS files must conform to the XML 1.0 specification, as published on the World Wide Web Consortium (W3C) website.

What is RSS XML file?

XML. RSS is a family of web feed formats used to publish frequently updated pages, such as blogs or news feeds. Really Simple Syndication (RSS 2.0) Rich Site Summary (RSS 0.91, RSS 1.0)

What is PubDate?

Name. PubDate -- The date of publication of a document.

What is RSS 2.0 feed?

Section 1: RSS 2.0 Based on the RSS 2.0 specification, there are 3 predefined elements at the item level: title, link, and description. Although these elements are optional in the RSS 2.0 standard, product data feeds require them. Product data feeds also require additional elements such as price, ID, and condition.


2 Answers

The PHP date function has already a way to format pubDate (RFC 2822) compliant dates:

date('r', $timestamp); 
like image 99
Nebel54 Avatar answered Sep 23 '22 15:09

Nebel54


Solved:

$pubDate = $article[creation_date];  $pubDate= date("D, d M Y H:i:s T", strtotime($pubDate)); 

then in my echo'd code:

 <pubDate>'.$pubDate.'</pubDate> 
like image 34
Thingamajig Avatar answered Sep 22 '22 15:09

Thingamajig