duaedf6509 2015-12-04 18:21
浏览 16

以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!

  • 写回答

1条回答 默认 最新

  • doukeyong3746487 2015-12-04 19:08
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码