如何将日期正确放置在< pubdate>中RSS feed上的元素 [英] How to properly place Date in <pubdate> element on RSS feed
问题描述
我正在使用RSS Graffitty将RSS项目发布到Facebook页面.
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']是从我的MySQL数据库获得的,它是一个Datetime列.
$row['Date'] is obtained from my MySQL database and it's a Datetime column.
如何格式化/回显它,以便RSS提要识别它?我必须更改元素吗?
How must I format it/echo it so it's recognized by the RSS feed? Must I change the element?
谢谢
推荐答案
RSS 2.0 规范, <pubDate>
元素应符合 RFC 822日期和时间语法.即,以以下格式显示它:
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:
2012年12月21日,星期五,格林尼治标准时间
Fri, 21 Dec 2012 10:00:01 GMT
如果您通过 W3C Feed验证程序错误运行RSS Feed,您将注意到以下示例有效的RFC822日期时间:
If you error run your RSS feed through the W3C Feed Validator you'll note these examples of valid RFC822 date-times:
<pubDate>Wed, 02 Oct 2002 08:00:00 EST</pubDate>
<pubDate>Wed, 02 Oct 2002 13:00:00 GMT</pubDate>
<pubDate>Wed, 02 Oct 2002 15:00:00 +0200</pubDate>
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')
或者您可以通过 PHP日期方法和 确保 Make sure your 还请注意,此元素区分大小写.您必须输出带有大写字母D的 Also note that this element is case-sensitive. You must output 这篇关于如何将日期正确放置在< pubdate>中RSS feed上的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!DATE_RSS
<pubDate>
元素出现在其父<item>
节点内.<pubDate>
element appear within its parent <item>
node.pubDate
,而不是其他所有元素都可以输出所有小写字母(pubdate
).pubDate
with the capital D and not all lowercase (pubdate
) as other elements can.