3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $start = DateTime::createFromFormat('d-m-Y', '25-12-2013'); $end = DateTime::createFromFormat('d-m-Y', '26-12-2013'); $dates = array('24-12-2013','25-12-2013','26-12-2014','27-12-2013'); $matches = array(); foreach ($dates as $date) { $date2 = DateTime::createFromFormat('d-m-Y', $date); echo $date2; if ($date2 >= $start && $date2 <= $end) { $matches[] = $date; } } print_r($matches);
based on tJmLL
Output for 7.1.0 - 7.2.0
Recoverable fatal error: Object of class DateTime could not be converted to string in /in/WN3pV on line 8
Process exited with code 255.
Output for 5.3.20 - 7.0.20
Catchable fatal error: Object of class DateTime could not be converted to string in /in/WN3pV on line 8
Process exited with code 255.