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 = "09/04/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); echo $working_days = strftime("%A, %d-%m-%Y",$newdate);
Output for 4.3.0 - 7.1.0
04-09-201305-09-201306-09-201307-09-201308-09-201309-09-201310-09-2013Tuesday, 10-09-2013