3v4l.org

run code in 200+ PHP versions simultaneously
<?php $spTimezone = new DateTimeZone('America/Sao_Paulo'); $baseTime = new DateTime('2015-06-23 18:00:00', $spTimezone); $expectedTimeString = $baseTime->format(DateTime::ATOM); echo "Expected time ", $expectedTimeString, "\n"; $baseDate = DateTime::createFromFormat(DateTime::ATOM, $expectedTimeString); $originalTimezone = $baseDate->getTimezone(); $baseDate->setTimezone($spTimezone); echo "SP TMZ ", $baseDate->format(DateTime::ATOM), "\n"; $baseDate->setTimezone($originalTimezone); echo "Original TMZ ", $baseDate->format(DateTime::ATOM), "\n"; $baseDate->setTimezone($spTimezone); echo "SP TMZ ", $baseDate->format(DateTime::ATOM), "\n"; $baseDate->setTimezone($originalTimezone); echo "Original TMZ ", $baseDate->format(DateTime::ATOM), "\n";
based on 9IfuP
Output for 7.0.20, 7.1.5 - 7.2.6
Expected time 2015-06-23T18:00:00-03:00 SP TMZ 2015-06-23T18:00:00-03:00 Original TMZ 2015-06-23T18:00:00-03:00 SP TMZ 2015-06-23T18:00:00-03:00 Original TMZ 2015-06-23T18:00:00-03:00
Output for 5.4.26 - 7.0.6, 7.1.0
Expected time 2015-06-23T18:00:00-03:00 SP TMZ 2015-06-23T18:00:00-03:00 Original TMZ 2015-06-23T18:00:00-03:00 SP TMZ 2015-06-23T15:00:00-03:00 Original TMZ 2015-06-23T15:00:00-03:00
Output for 5.3.0 - 5.4.25
Expected time 2015-06-23T18:00:00-03:00 SP TMZ 2015-06-23T18:00:00-03:00 Warning: DateTime::setTimezone(): Can only do this for zones with ID for now in /in/1idd6 on line 15 Original TMZ 2015-06-23T18:00:00-03:00 SP TMZ 2015-06-23T18:00:00-03:00 Warning: DateTime::setTimezone(): Can only do this for zones with ID for now in /in/1idd6 on line 21 Original TMZ 2015-06-23T18:00:00-03:00
Output for 5.2.10 - 5.2.17
Expected time 2015-06-23T18:00:00-03:00 Fatal error: Call to undefined method DateTime::createFromFormat() in /in/1idd6 on line 9
Process exited with code 255.
Output for 5.2.0 - 5.2.9
Expected time 2015-06-23T18:00:00-03:00 Fatal error: Call to undefined method DateTime::createfromformat() in /in/1idd6 on line 9
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTimeZone' not found in /in/1idd6 on line 2
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected ')', expecting '(' in /in/1idd6 on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected ')', expecting '(' in /in/1idd6 on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'('' in /in/1idd6 on line 5
Process exited with code 255.