3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class MyDateTime extends DateTime { public static function createFromFormat($format, $time, $timezone = null) { $version = explode('.', phpversion()); if(!$timezone) $timezone = new DateTimeZone(date_default_timezone_get()); if(((int)$version[0] >= 5 && (int)$version[1] >= 2 && (int)$version[1] >= 17)){ return parent::createFromFormat($format, $time, $timezone); } return new DateTime(date($format, strtotime($time)), $timezone); } } $dateTime = MyDateTime::createFromFormat('Y-m-d', '2013-6-13'); var_dump($dateTime); var_dump($datetime->format('Y-m-d');
Output for 5.3.0 - 5.4.16
Parse error: syntax error, unexpected ';' in /in/pJVpg on line 17
Process exited with code 255.