将int date转换为RSS PubDate RFC 822 PHP
我有个问题让我发疯, 我的任务是解析API中的日期,并将其转换为RFC 822格式,因为即将发布的提要会出现验证错误 API中的日期如下所示:将int date转换为RSS PubDate RFC 822 PHP,php,validation,rss,w3c,pubdate,Php,Validation,Rss,W3c,Pubdate,我有个问题让我发疯, 我的任务是解析API中的日期,并将其转换为RFC 822格式,因为即将发布的提要会出现验证错误 API中的日期如下所示: <review created="2012-10-23 14:51:12.0"> 此日期将呈现为: 23.10.2012 为了我的约会 $xtime = substr($review["created"], 0, 16); $xxl = $pubtime . " GMT"; 呈现为: 2012-10-23 14:51:12 GMT W
<review created="2012-10-23 14:51:12.0">
此日期将呈现为:
23.10.2012
为了我的约会
$xtime = substr($review["created"], 0, 16);
$xxl = $pubtime . " GMT";
呈现为:
2012-10-23 14:51:12 GMT
W3C feed validator说它不是validate,因为pubDate不是RFC822格式的
Sorry
This feed does not validate.
line 10, column 38: pubDate must be an RFC-822 date-time: 2012-10-29 11:51:23 GMT (5 occurrences) [help]
<pubDate>2012-10-29 11:51:23 GMT</pubDate>
对不起
此提要未验证。
第10行第38列:pubDate必须是RFC-822日期时间:2012-10-29 11:51:23 GMT(5次出现)[帮助]
2012-10-29 11:51:23格林威治标准时间
它需要看起来像:
<pubDate>Wed, 02 Oct 2002 13:00:00 GMT</pubDate>
2002年10月2日星期三格林威治标准时间13:00:00
我可以想象一个表达“if(month=01){actualmonth=Jan}”之类的内容的简单解决方案,但我真的不知道如何处理这些天
另外,我对PHP不太熟悉,但我需要尽快解决这个问题
希望你能帮助我,一定有我在类似问题中没有找到的解决方案
关于John,在PHP中你应该看看这个:在PHP中你应该看看这个:看看
DateTime::createFromFormat()
或date\u create\u from\u format
看看可能的日期格式
编辑:修复了
DateTime::createFromFormat()
或date\u create\u from\u format
看看可能的日期格式
编辑:修复了是啊对我有效的问题,太棒了 对于其他人来说,我的案例的确切解决方案是
非常感谢你的快速回答,你太棒了 是啊,对我来说很有效,太棒了 对其他人来说,我的案子的确切解决办法是
非常感谢你的快速回答,你太棒了 这对我有用
date("r", strtotime($yourdate))
$yourdate是2013-10-27,我得到了太阳,2013年10月27日00:00:00+0000这对我很有效
date("r", strtotime($yourdate))
$yourdate是2013-10-27,我得到了太阳,2013年10月27日00:00:00+0000
$before = "2012-10-23 14:51:12.0";
$timetwo = substr($before, 0, 16);
$timethree = date_create_from_format('Y-m-d H:i:s', $timetwo);
$timefinal = date_format(timethree, 'D, d M Y H:i:s');
$after = $timefinal . ' GMT' ;
$after = "Mon, 23 Oct 2012 14:51:12 GMT";
date("r", strtotime($yourdate))