3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class MyDateTime extends DateTime { public static function createFromFormat($format, $time, $timezone = null) { if(!$timezone) $timezone = new DateTimeZone(date_default_timezone_get()); $version = explode('.', phpversion()); 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', '2013-6-13'); var_dump($dateTime); var_dump($dateTime->format('Y-m-d')); $inputDate = "wrz 2013 2 12:00:00:000"; $polishMonths = array("sty", "lut", "mar", "kwi", "maj", "cze", "lip", "sie", "wrz", "paz", "lis", "gru"); $englishMonths = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); $r2pDate = str_replace($polishMonths, $englishMonths, $inputDate); $dateTime = MyDateTime::createFromFormat('M Y j H:i:s:u', $r2pDate); var_dump($dateTime); var_dump($dateTime->format('Y-m-d H:i:s');
Output for 7.0.0 - 7.1.0
Parse error: syntax error, unexpected ';', expecting ',' or ')' in /in/GZlbJ on line 27
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Fatal error: syntax error, unexpected ';', expecting ')' in /in/GZlbJ on line 27
Process exited with code 255.
Output for 5.3.0 - 5.6.21
Parse error: syntax error, unexpected ';' in /in/GZlbJ on line 27
Process exited with code 255.