Hi, how do I compute the business days in a week given the parameters: start date, end date and current week? The duration of the range for the start date and end date may go over a year.
edit: thanks for the welcome! business days are from mon-fri.
Hi, how do I compute the business days in a week given the parameters: start date, end date and current week? The duration of the range for the start date and end date may go over a year.
edit: thanks for the welcome! business days are from mon-fri.
the code bellow displays only business days between two dates :
$start_date = '2010-02-01';
$end_date = '2010-02-28';
$next_date = $start_date;
while ($next_date != $end_date) {
if (date('N',strtotime($next_date)) < 6) echo $next_date."\n";
$next_date = date('Y-m-d', strtotime($next_date.' +1 day'));
}
date('N',$sometimestamp) gives you the numeric representation of the day of the week : 1 (for Monday) through 7 (for Sunday)