如何将日期正确放置在< pubdate>中RSS feed上的元素 [英] How to properly place Date in <pubdate> element on RSS feed

查看:97
本文介绍了如何将日期正确放置在< pubdate>中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>

如果您想使用MySQL格式,则可以使用以下

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日期方法DATE_RSS

确保<pubDate>元素出现在其父<item>节点内.

Make sure your <pubDate> element appear within its parent <item> node.

还请注意,此元素区分大小写.您必须输出带有大写字母D的pubDate,而不是其他所有元素都可以输出所有小写字母(pubdate).

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.

这篇关于如何将日期正确放置在&lt; pubdate&gt;中RSS feed上的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆