note 60795 deleted from function.date by didou
| From: | didou@php.net | Date: | Mon, 24 Apr 2006 18:14:41 +0000 |
| Subject: | note 60795 deleted from function.date by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-109571@lists.php.net to get a copy of this message | ||
Note Submitter: Brian W. Spolarich
Reason: 3
----
In case you need to count the number of "business days" between two dates (timestamps) you
can do something like this:
function date_business_day_diff($start_date, $end_date)
{
$business_days = 0;
if ($start_date < $end_date) {
$date1 = $start_date;
$date2 = $end_date;
} else {
$date1 = $end_date;
$date2 = $start_date;
} while ($date1 < $date2) {
$thedate = getdate($date1);
// Skip saturday or sunday.
if (($thedate["wday"] != '0') and ($thedate["wday"] !=
'6')) {
$business_days++;
}
$date1 += 86400; // Add a day.
}
return $business_days;
}