note 97406 added to function.date
| From: | robin at stylr dot nl | Date: | Sun, 18 Apr 2010 18:50:52 +0000 |
| Subject: | note 97406 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-168372@lists.php.net to get a copy of this message | ||
This is a little function that returns only a working day (monday until friday). It's flexible
due to the use of a 'forbidden days' array.
I used this in a project where the delivery date can only be 10 days from now and only on a working
day (mo - fr).
function wdays($strTime = NULL){
$arrWeekend = array("6","7"); // saturday and sunday
$strTime = (is_null($strTime)) ? strtotime("+10 days") : $strTime;
if(in_array(date("N", $strTime), $arrWeekend)){
return wdays(strtotime("+1 day", $strTime));
}
else {
return $strTime;
}
}
echo date("d-m-Y",wdays());
----
Server IP: 69.147.83.197
Probable Submitter: 200.26.222.141
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/97406
Del: integrated -- https://master.php.net/note/delete/97406/integrated
Del: useless -- https://master.php.net/note/delete/97406/useless
Del: bad code -- https://master.php.net/note/delete/97406/bad+code
Del: spam -- https://master.php.net/note/delete/97406/spam
Del: non-english -- https://master.php.net/note/delete/97406/non-english
Del: in docs -- https://master.php.net/note/delete/97406/in+docs
Del: other reasons-- https://master.php.net/note/delete/97406
Reject -- https://master.php.net/note/reject/97406
Search -- https://master.php.net/manage/user-notes.php