开发者

What is the best way to parse a RSS pubDate in PHP?

I get a RSS开发者_如何学JAVA and I manage it with PHP: I parse it, and I get the date value with :

$data_feed=$item[pubdate];

If I print this date, I get for example :

Wed, 05 Oct 2011 00:00:00 PST

I know that on RSS there are many date format, such as PST, EST, GMT, +0200 and son on.

How can I Parse on PHP any kind of date format from a RSS? As example, I'd like to have always the format DD-MM-YYYY.


strtotime will handle most common formats.

From there, you can use strftime to display the format you'd like.


This simple command works for me:

$date = date_create_from_format(DateTime::RSS, $string);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜