简体   繁体   English

使用 php 代码从 rss pubDate 时区转换日期

[英]Conversion of date from rss pubDate timezone using php code

I got this date from rss pubDate attribute:我从 rss pubDate 属性中得到了这个日期:

Fri, 22 Sep 2017 19:53:01 GMT

I need to convert it to:我需要将其转换为:

Wed, 23 Aug 2017 19:20:30 +0000

So i need a mean to translate the timezone(GMT to +000).所以我需要一个方法来翻译时区(GMT 到 +000)。 I'm going to use this string here:我将在这里使用这个字符串:

<time class="timeago" datetime="'. $pubDate .'"></time>
$date = date_create_from_format(DateTime::RSS, $pubDate);
$pubDateStr = $date->format("r");

This code will do the conversion.此代码将进行转换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM