3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $holidayList = array("04-03-2008","07-03-2008"); $j = $i = 0; //changed this to 0 or you were always starting one day ahead $given_date = "04/09/2013 13:06:00"; $tmp1 = strtotime($given_date); //worked out a timstamp to start with while($i < 5) { $tmp2 = strtotime("+$j day", $tmp1); $day = strftime("%A",$tmp2); echo strftime("%d-%m-%Y",$tmp2); $tmp = strftime("%d-%m-%Y",$tmp2); if(($day != "Sunday") && ($day != "Saturday" )&&(!in_array($tmp, $holidayList))) { $i = $i + 1; $j = $j + 1; } else { $j = $j + 1; } } $j = $j -1; $newdate = strtotime("+$j day",$tmp1); $working_days = strftime("%A, %d-%m-%Y",$newdate);
Output for 4.3.0 - 7.1.0
09-04-201310-04-201311-04-201312-04-201313-04-201314-04-201315-04-2013