3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $beginday=date('Y-m-01'); $lastday=date('Y-m-t'); $nr_work_days = getWorkingDays($beginday,$lastday); echo $nr_work_days; function getWorkingDays($startDate, $endDate){ $begin=strtotime($startDate); $end=strtotime($endDate); if($begin>$end){ echo "startdate is in the future! <br>"; return 0; }else{ $working_days=0; $total_days=0; while($begin<=$end){ $what_day=date("N",$begin); $total_days++; if($what_day<=5) { // 6 and 7 are weekend days $working_days++; }; $begin+=86400; // +1 day }; $testString = "hours to subtract: " . ($working_days * 8) + (($total_days - $working_days)*24); return $testString; } } ?>
based on dLdqT
Output for 7.1.0
Warning: A non-numeric value encountered in /in/WdvDG on line 26 216
Output for 5.1.0 - 7.0.14
216
Output for 4.3.0 - 5.0.5
0