convert soap time in PHP

date, php

Solution

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

This will echo,

2013-10-29 08:34:01

The DateTime class in PHP is very powerful, and will recognise almost any format you throw at it. It's great for manipulation.

Problem

I am getting time in the following format as a response of an API call. How I can I convert it to Y-m-d H:i:s I used the following : ``` $time_other_format = '2013-10-29T08:34:01-0700'; $time = date("Y-m-d H:i:s",strtotime($time_other_format)); ``` This is returning the time, but the time is changed and I think as per the timezone. I have records in DB which are inserted before the convesrion and so retain the original time and to compare it. How can I convert it like that . I mean I need to get the time as 08:34:01 after converting it

Original source