Peter Senyszyn Peter Senyszyn - 27 days ago 4x
SQL Question

Changing ISO 8601 date string to 24 hours from its current value

I have an ISO 8601 string like so:


Now, I want to push the date forward 24 hours, but in the "Y-m-d H:i:s" format. I experimented with the following:

//$date1 is ISO 8601 string
date("Y-m-d H:i:s", strtotime($date1, '+24 hours'));

But unfortunately that's not working. Am I on the right track or completely wrong?



Use the DateTime class. Make a new instance, add 24 hours to it and format it.

$dt = new DateTime('2016-09-26T20:38:15.793Z');
$dt->modify('+24 hours'); 
echo $dt->format('Y-m-d H:i:s');