简体   繁体   中英

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

I get a RSS 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.

这个简单的命令对我有用:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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