3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $start = "07/01/2015-08/01/2015"; //split the start and end date in to 2 and compare both to a real date to make sure they're valid $newdate = explode("-", $start); echo 1; //make sure date 2 is set if(!isset($newdate[1])): echo "No date 2\n"; endif; //check if newdate 0 and 1 are real dates $date1 = DateTime::createFromFormat('M-d-Y', str_replace("/","-",$newdate[0])); $date2 = DateTime::createFromFormat('M-d-Y', str_replace("/","-",$newdate[1])); echo str_replace("/","-",$newdate[0]); //not valid dates if($date1 == false || $date2 == false): echo "Invalid dates\n"; endif; echo 4;
based on W9ABu
Output for 5.3.0 - 7.2.0
107-01-2015Invalid dates 4
Output for 5.2.10 - 5.2.17
1 Fatal error: Call to undefined method DateTime::createFromFormat() in /in/aHocF on line 11
Process exited with code 255.
Output for 5.2.0 - 5.2.9
1 Fatal error: Call to undefined method DateTime::createfromformat() in /in/aHocF on line 11
Process exited with code 255.
Output for 5.0.0 - 5.1.6
1 Fatal error: Class 'DateTime' not found in /in/aHocF on line 11
Process exited with code 255.
Output for 4.3.2 - 4.4.9
1 Fatal error: Undefined class name 'datetime' in /in/aHocF on line 11
Process exited with code 255.
Output for 4.3.0 - 4.3.1
1 Fatal error: Undefined class name 'datetime' in /in/aHocF on line 11