3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $date = '2015-01-01T00:00:00.000'; echo "Set timezone using construct:\n"; $dateTime = new DateTime($date); $dateTime->setTimezone(new DateTimeZone('America/Mexico_City')); echo $dateTime->format('c'). "\n\n"; echo "Set timezone using method:\n"; $dateTime = new DateTime($date); $dateTime->setTimezone(new DateTimeZone('America/Mexico_City')); echo $dateTime->format('c'). "\n";
based on iFeeJ
Output for 5.2.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Set timezone using construct: 2014-12-31T17:00:00-06:00 Set timezone using method: 2014-12-31T17:00:00-06:00
Output for 5.0.0 - 5.1.6
Set timezone using construct: Fatal error: Class 'DateTime' not found in /in/dII1B on line 7
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Set timezone using construct: Fatal error: Cannot instantiate non-existent class: datetime in /in/dII1B on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Set timezone using construct: Fatal error: Cannot instantiate non-existent class: datetime in /in/dII1B on line 7