note 81499 added to function.date
| From: | dizyn at hotmail dot comM dot AbdulMannan | Date: | Sat, 01 Mar 2008 14:17:25 +0000 |
| Subject: | note 81499 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-136636@lists.php.net to get a copy of this message | ||
This small snippet of code will calculate date after five business days. This will exclude Sunday,
Saturday and the holidays list thatâs given in array.
Date for example: 1st March 2008
<?php
$holidayList = array("04-03-2008","07-03-2008");
$j = $i = 1;
while($i <= 5)
{
$day = strftime("%A",strtotime("+$j day"));
$tmp = strftime("%d-%m-%Y",strtotime("+$j day"));
if($day != "Sunday" and $day != "Saturday" and !in_array($tmp, $holidayList))
{
$i = $i + 1;
$j = $j + 1;
}
else
$j = $j + 1;
}
$j = $j -1;
echo strftime("%A, %d-%m-%Y",strtotime("+$j day"));
?>
Result: Tuesday, 11-03-2008
----
Server IP: 69.147.83.197
Probable Submitter: 58.65.152.54
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/81499
Del: integrated -- https://master.php.net/note/delete/81499/integrated
Del: useless -- https://master.php.net/note/delete/81499/useless
Del: bad code -- https://master.php.net/note/delete/81499/bad+code
Del: spam -- https://master.php.net/note/delete/81499/spam
Del: non-english -- https://master.php.net/note/delete/81499/non-english
Del: in docs -- https://master.php.net/note/delete/81499/in+docs
Del: other reasons-- https://master.php.net/note/delete/81499
Reject -- https://master.php.net/note/reject/81499
Search -- https://master.php.net/manage/user-notes.php