3v4l.org

run code in 300+ PHP versions simultaneously
<?php $given_date = '04/09/2013 13:06:00'; list ($date, $time) = explode(' ', $given_date); //separate date and time list ($day, $month, $year) = explode('/', $date);//separate day, month and year //convert the uk date to the us date format and work out a timstamp to start with $usdate= strtotime("$month/$day/$year"); //create an array of bank holidays $holidayList = array("04-03-2008","07-03-2008"); $j = $i = 0; //compute 5 working days while($i < 5) { $tmp2 = strtotime("+$j day", $usdate); // get the timestamp of the date $day = strftime("%A",$tmp2); //get day in plain English $tmp = strftime("%d-%m-%Y",$tmp2); //get full date in uk format //add 1 to $i only if it's not Sat or Sun or a bank holiday if(($day != "Sunday") && ($day != "Saturday" )&&(!in_array($tmp, $holidayList))) { $i = $i++; $j = $j++; } else { $j = $j + 1; } } //$j = $j -1; $newdate = strtotime("+$j day",$usdate); echo strftime("%A, %d-%m-%Y",$newdate);

preferences:
37.42 ms | 402 KiB | 5 Q