我有一个让我抓狂的问题,我的任务是从 API 解析日期并将其转换为 RFC 822 格式,因为输出的提要出现验证错误
API 中的日期如下所示:
<review created="2012-10-23 14:51:12.0">
我在通过 substr 进行的描述中有一个日期
$xtime = substr($review["created"], 0, 16);
$jahr = substr($xtime,0,4);
$mon = substr($xtime,5,2);
$tag = substr($xtime,8,2);
$datneu = $tag.'.'.$mon.'.'.$jahr;
此日期将呈现为:
23.10.2012
对于我所做的发布
$xtime = substr($review["created"], 0, 16);
$xxl = $pubtime . " GMT";
呈现为:
2012-10-23 14:51:12 GMT
W3C 提要验证器说它没有验证,因为 pubDate 不是 RFC 822 形式
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>
它需要看起来像:
<pubDate>Wed, 02 Oct 2002 13:00:00 GMT</pubDate>
我可以想象一个 hacky 解决方案来表达“if (month = 01){ actualmonth = Jan}”,但我真的不知道如何处理这些日子,
另外我对 PHP 不太满意,但我需要尽快解决这个问题。
希望你能帮助我,一定有一个我在类似问题上没有找到的解决方案
问候约翰