How to properly place Date in element on RSS feed

前端 未结 2 1941
轮回少年
轮回少年 2020-12-31 14:45

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          


        
2条回答
  •  长情又很酷
    2020-12-31 15:12

    RSS 2.0 specifications on the element should conform to the RFC 822 Date and Time syntax. Namely, to display it in the following format:

    Fri, 21 Dec 2012 10:00:01 GMT

    If you error run your RSS feed through the W3C Feed Validator you'll note these examples of valid RFC822 date-times:

    Wed, 02 Oct 2002 08:00:00 EST
    
    Wed, 02 Oct 2002 13:00:00 GMT
    
    Wed, 02 Oct 2002 15:00:00 +0200
    

    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:

    date_format(Date, '%a, %d %b %Y %H:%i:%s')
    

    Or you can do it via the PHP date method with DATE_RSS setting the format for you:

    echo "".date(DATE_RSS, strtotime($row['Date']))."";
    

    Make sure your element appear within its parent node.

    Also note that this element is case-sensitive. You must output pubDate with the capital D and not all lowercase (pubdate) as other elements can.

提交回复
热议问题