php count days excluding weekends code example
Example: php count days excluding weekends
function sumDays($days = 0, $format = 'd/m/Y') {
$incrementing = $days > 0;
$days = abs($days);
$actualDate = date('Y-m-d');
while ($days > 0) {
$tsDate = strtotime($actualDate . ' ' . ($incrementing ? '+' : '-') . ' 1 days');
$actualDate = date('Y-m-d', $tsDate);
if (date('N', $tsDate) < 6) {
$days--;
}
}
return date($format, strtotime($actualDate));
}