开发者

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

开发者 https://www.devze.com 2023-04-11 00:15 出处:网络
I get a RSS开发者_如何学JAVA and I manage it with PHP: I parse it, and I get the date value with :

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

精彩评论

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