用PHP转换肥皂时间
发布时间:2020-12-13 13:28:22 所属栏目:PHP教程 来源:网络整理
导读:我正在以下面的格式获得时间作为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)); 这是返回时间,但时间会改变,我认为按照时区
我正在以下面的格式获得时间作为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)); 这是返回时间,但时间会改变,我认为按照时区.我在DB中有记录,这些记录在convesrion之前插入,因此保留原始时间并进行比较.我怎么能这样转换它.我的意思是我需要在转换后将时间设为08:34:01 $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类非常强大,几乎可以识别您抛出的任何格式.它非常适合操纵. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |