3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?phpclass 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[2] > 17)){ return parent::createFromFormat($format, $time, $timezone); } return new DateTime(date($format, strtotime($time)), $timezone); } } $dateTime = MyDateTime::createFromFormat('Y-m-d H:i:s', '2014-12-12 12:12:00'); var_dump($dateTime); var_dump($dateTime->format('Y-m-d'));
Output for 5.4.0 - 5.4.35
Parse error: syntax error, unexpected 'MyDateTime' (T_STRING) in /in/BnbWj on line 1
Process exited with code 255.