note 60795 added to function.date

From: Date: Mon, 16 Jan 2006 21:39:40 +0000
Subject: note 60795 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-101943@lists.php.net to get a copy of this message
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; } ---- Server IP: 12.160.245.96Probable Submitter: 68.40.207.18 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60795 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60795&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60795&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60795&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60795&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60795&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60795&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60795&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60795&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#101943) next »