【问题标题】:convert soap time in PHP在 PHP 中转换肥皂时间
【发布时间】:2013-11-28 19:28:55
【问题描述】:

我得到以下格式的时间作为 API 调用的响应。如何将其转换为 Y-m-d H:i:s 我使用了以下内容:

$time_other_format = '2013-10-29T08:34:01-0700';

$time = date("Y-m-d H:i:s",strtotime($time_other_format));

这是返回时间,但时间已更改,我认为是根据时区。我在数据库中有记录,这些记录是在转换之前插入的,因此保留了原始时间并进行比较。我怎么能像那样转换它。我的意思是我需要在转换后将时间设为 08:34:01

【问题讨论】:

    标签: php date


    【解决方案1】:
    $time_other_format = '2013-10-29T08:34:01-0700';
    $dt = new DateTime($time_other_format);
    echo $dt->format('Y-m-d H:i:s');
    

    这会回响,

    2013-10-29 08:34:01
    

    PHP 中的DateTime 类非常强大,几乎可以识别任何格式。非常适合操控。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多