donglang1894 2012-09-09 21:37
浏览 1187
已采纳

如何转换yyyy-MM-ddTHH:mm:ssZ到yyyy-MM-dd HH:mm:ss?

Paypal returns a timestamp of the following format:

yyyy-MM-ddTHH:mm:ssZ

And I don't quite know what to do with it...

How can I convert it to yyyy-MM-dd HH:mm:ss using my local timezone in php?

I'm tempted to preg_replace the mysterious letters, but something tells me there must a better way. There also appears to be 8 hours difference to my zone which I'm not sure how to substract.

  • 写回答

2条回答 默认 最新

  • dousa2794 2012-09-09 21:41
    关注

    Use DateTime class to do your magic.

    $date = new DateTime('2012-09-09T21:24:34Z');
    $date->format('Y-m-d'); # read format from date() function
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 帮我调试idea基于spring boot项目
  • ¥15 es 7.17.20版本生成时间戳
  • ¥15 wpf dategrid表头排序图标自定义
  • ¥15 分析下图所示同步时序逻辑电路的逻辑功能。
  • ¥15 halcon联合c#遇到了问题不能解决
  • ¥15 xshell无法连接提示ssh服务器拒绝密码
  • ¥15 AT89C52单片机C语言关于串口通信的位操作
  • ¥20 需要步骤截图(标签-服务器|关键词-map)
  • ¥50 gki vendor hook
  • ¥15 灰狼算法和蚁群算法如何结合