以Php格式化日期

I am trying to parse 3 RSS feeds for titles, links, and dates for every item. While the xml for titles and links are the same across the RSS (, ), the dates (including the time) are formatted differently across the 3, but in the interest of creating a Php object where I aggregate all the dates to display on a map, they need to be formatted similarly. I'm currently trying to use the Php function (strtotime - http://php.net/manual/en/function.strtotime.php) to create a UNIX timestamp. Does anyone know if this is the right way to do it?

The 3 date formats I currently have are:

  • Wed, 25 Nov 2015 17:20:18 +0000

  • 03 Dec 2015 21:30:00 GMT

  • 2015-12-10T05:00:00Z

Thanks!

For this type of solutions do you have the design pattern Chain-Of-Responsibility, see for instance https://en.wikipedia.org/wiki/Chain-of-responsibility_pattern.

Every part of the chain knows how to deal with a specific format. It will check if the data is consistent with the format or not. If not, then will it pass the data to the next class in the chain. If it succeeds, then will the process stop and you will have your result. If you need more formats in the future, then will you be able to extend the chain with another implementation without changing that what already works as designed.

An uml of the design pattern can be found here: http://www.oodesign.com/chain-of-responsibility-pattern.html.