3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php date_default_timezone_set('Europe/London'); $format = 'Y-m-d H:i e'; $times = array( '2015-10-24 15:00:00 01:00:00 BST', '2015-10-25 15:00:00 01:00:00 BST', '2015-10-26 15:00:00 01:00:00 BST' ); foreach ($times as $time) { $dt = DateTime::createFromFormat('Y-m-d H:i:s T', $time, new DateTimeZone('Europe/London')); echo "Localised:\n"; echo $dt->format($format) . "\n\n"; echo "Putting into UTC:\n"; $dt->setTimezone(new DateTimeZone('UTC')); echo $dt->format($format) . "\n\n"; }
based on WjpvU
Output for 7.0.0 - 7.2.0
Localised: Fatal error: Uncaught Error: Call to a member function format() on boolean in /in/j8F9R:16 Stack trace: #0 {main} thrown in /in/j8F9R on line 16
Process exited with code 255.
Output for 5.6.7 - 5.6.28
Localised: Fatal error: Call to a member function format() on boolean in /in/j8F9R on line 16
Process exited with code 255.
Output for 5.3.19 - 5.5.35
Localised: Fatal error: Call to a member function format() on a non-object in /in/j8F9R on line 16
Process exited with code 255.