The object is to be able to pass some dates (start date, holiday) and the number of days you want to skip. We only want to skip working days, not weekends and holidays.
Just let me know what you'd do different than what I have. The code works, but I was told there are issues with it, but not told what issues they are.
function getWDays($startDate,$holiday,$wDays){
$d = new DateTime( $startDate );
$t = $d->getTimestamp();
$h = strtotime($holiday);
// loop for $wDays days
for($i=0; $i<$wDays; $i++){
// 1 day = 86400 seconds
$addDay = 86400;
$nextDay = date('w', ($t+$addDay));
if($nextDay == 0 || $nextDay == 6) {
$i--;
}
$t = $t+$addDay;
if ($t == $h) {
// lets make sure the holiday isn't one of our weekends
if(!$nextDay == 0 || !$nextDay == 6) {
$t = $t+$addDay;
}
}
}
$d->setTimestamp($t);
return $d->format( 'Y-m-d' );
}
echo getWDays("2013-08-29","2013-09-02", 3)