3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $start_date = '2014-3-19'; $end_date = '2014-5-19'; $begin = new DateTime( $start_date ); $end = new DateTime(date("Y-m-d",strtotime("+1 day", strtotime($end_date)))); while($begin < $end) { $period[] = $begin->format('Y-m-d'); $begin->modify('+1 day'); } foreach($period as $val) { print_r($val); print_r(isWeekend($val)); } function isWeekend($date) { return (date('N', strtotime($date)) >= 6); }
Output for 5.2.2 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
2014-03-192014-03-202014-03-212014-03-2212014-03-2312014-03-242014-03-252014-03-262014-03-272014-03-282014-03-2912014-03-3012014-03-312014-04-012014-04-022014-04-032014-04-042014-04-0512014-04-0612014-04-072014-04-082014-04-092014-04-102014-04-112014-04-1212014-04-1312014-04-142014-04-152014-04-162014-04-172014-04-182014-04-1912014-04-2012014-04-212014-04-222014-04-232014-04-242014-04-252014-04-2612014-04-2712014-04-282014-04-292014-04-302014-05-012014-05-022014-05-0312014-05-0412014-05-052014-05-062014-05-072014-05-082014-05-092014-05-1012014-05-1112014-05-122014-05-132014-05-142014-05-152014-05-162014-05-1712014-05-1812014-05-19
Output for 5.2.0 - 5.2.1
Notice: Undefined variable: period in /in/vLvpH on line 13 Warning: Invalid argument supplied for foreach() in /in/vLvpH on line 13
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/vLvpH on line 6
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/vLvpH on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/vLvpH on line 6