Hi all,
I was hoping that you could help me with the following function. I am trying to calculate the diff between 2 dates and return the value excluding the weekend. This function sometimes works but with certain dates it just returns 0. I’m using this for a calendar for a work project and dont want to include the weekend dates from their holiday entitlement. If you have any ideas or a better method for this it would be greatly appreciated.
Thanks Paul
[php]
function dateDiffExcludeWeekends($startDate, $endDate) {
echo $startDate . " " . $endDate . “
”;
// Sets the Count
$count = 0;
$startStt = strtotime($startDate);
$endStt = strtotime($endDate);
// iterates through each day till the end day is back at the start date
while (date(“j-n-Y”, $startStt) <= date(“j-n-Y”,$endStt)){
$count = (date(“w”, $endStt) != 0 && date(“w”, $endStt) != 6) ? $count +1 : $count;
$endStt = $endStt - 86400;
}
return $count;
}
echo "Days: " . dateDiffExcludeWeekends(‘6-1-2012’,‘10-1-2012’);
[/php]