I received a date string from API respond like this
"2013-07-09T04:58:23.075Z"
How can I parse that string, say to change format to
2013-07-09 [04:58:23]
The time indeed is not based on my local time, I think the .075Z should change something about the time.
Thanks in advance for your help.
You can do that using the DateTime object
.
$Date = new DateTime('2013-07-09T04:58:23.075Z'); //create dateTime object
$Date->setTimezone(new DateTimeZone('Europe/Amsterdam')); //set the timezone
echo $Date->format('d/m/Y H:i');
try this
$date = '2013-07-09T04:58:23.075Z';
$seconds = strtotime($date);
echo date('Y-m-d [H:i:s]', $seconds);
Hope it helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With