note 87283 added to function.date
| From: | Anonymous at osu1 dot php dot net | Date: | Thu, 27 Nov 2008 21:59:20 +0000 |
| Subject: | note 87283 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-147053@lists.php.net to get a copy of this message | ||
re: june at overlie dot no
Reverse of getWorkingDays() function.
function getTargetWorkingDate($startDate, $days, $holidays = null) {
$the_first_day_of_week = date("N",strtotime($startDate));
if($the_first_day_of_week == 6) $b_extra+=2;
if($the_first_day_of_week == 7) $b_extra++;
$startDate = getdate((($b_extra) * 86400) + strtotime($startDate));
$startDate = $startDate['year'] . "-" . $startDate['mon'] .
"-" . $startDate['mday'];
$no_weeks = floor($days / 5);
$extra_days = $no_weeks * 2;
$endDate = getdate((($days+$extra_days) * 86400) + strtotime($startDate));
$endDate = $endDate['year'] . "-" . $endDate['mon'] .
"-" . $endDate['mday'];
if($holidays) {
foreach($holidays as $holiday){
$time_stamp = strtotime($holiday);
if (strtotime($startDate) <= $time_stamp && $time_stamp <= strtotime($endDate)
&& date("N",$time_stamp) != 6 && date("N",$time_stamp) != 7)
$extra_days++;
}
}
$endDate = getdate((($days+$extra_days) * 86400) + strtotime($startDate));
$endDate = $endDate['year'] . "-" . $endDate['mon'] .
"-" . $endDate['mday'];
$the_last_day_of_week = date("N",strtotime($endDate));
if($the_last_day_of_week == 6) $e_extra+=2;
if($the_last_day_of_week == 7) $e_extra++;
$endDate = getdate((($e_extra) * 86400) + strtotime($endDate));
$endDate = $endDate['year'] . "-" . $endDate['mon'] .
"-" . $endDate['mday'];
return $endDate;
}
----
Server IP: 194.8.30.16
Probable Submitter: 82.154.53.129
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/87283
Del: integrated -- https://master.php.net/note/delete/87283/integrated
Del: useless -- https://master.php.net/note/delete/87283/useless
Del: bad code -- https://master.php.net/note/delete/87283/bad+code
Del: spam -- https://master.php.net/note/delete/87283/spam
Del: non-english -- https://master.php.net/note/delete/87283/non-english
Del: in docs -- https://master.php.net/note/delete/87283/in+docs
Del: other reasons-- https://master.php.net/note/delete/87283
Reject -- https://master.php.net/note/reject/87283
Search -- https://master.php.net/manage/user-notes.php