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) { if(isWeekend($begin)) $period[] = $begin->format('Y-m-d'); $begin->modify('+1 day'); } foreach($period as $val) { print_r("Value: " . $val . (isWeekend($val) ? " - weekend\n" : " - weekday\n")); } function isWeekend($date) { return (date('N', strtotime($date)) >= 6); }
Output for 5.2.2 - 5.6.28, 7.0.0 - 7.1.0
Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Notice: Undefined variable: period in /in/e6dXd on line 14 Warning: Invalid argument supplied for foreach() in /in/e6dXd on line 14
Output for hhvm-3.10.0 - 3.12.0
Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19 Warning: strtotime() expects parameter 1 to be string, object given in /in/e6dXd on line 19
Output for 5.2.0 - 5.2.1
Notice: Undefined variable: period in /in/e6dXd on line 14 Warning: Invalid argument supplied for foreach() in /in/e6dXd on line 14
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/e6dXd 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/e6dXd 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/e6dXd on line 6