note 55890 added to function.date
| From: | steve at somejunkwelike dot com | Date: | Tue, 16 Aug 2005 18:01:32 +0000 |
| Subject: | note 55890 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93759@lists.php.net to get a copy of this message | ||
re: Paul_liversidge...
This is a way to get the next 10 business days, by comparing the day of the week to not be saturday
or sunday. change the top two variables to get various different results... if you want to get the
next 10 business days, starting in two days from today, change the first variable to 2, and the
second to 14. This should yield the next 10 working days.
<?php
$how_many_business_days_ahead = 0;
$how_many_business_days_to_count = 7;
for ($i=0;$i<$how_many_business_days_to_count;$i++)
{
$jump=$i+$how_many_business_days_ahead;
$evalday = mktime(strftime ("%d/%m/%Y", strtotime("+$jump days")));
$theday = strftime("%A", strtotime("+$jump days"));
if($theday != "Saturday" and $theday != "Sunday")
{
$days = $how_many_business_days_ahead+$i;
$the_days[$j] = strftime("%A, %B %d, %Y", strtotime("+$jump days"));
$j++;
}
}
$k = $how_many_business_days_ahead;
foreach($the_days as $eachday)
{
echo "$k business days from now = $eachday<br />";
$k++;
}
?>
results:
0 business days from now = Tuesday, August 16, 2005
1 business days from now = Wednesday, August 17, 2005
2 business days from now = Thursday, August 18, 2005
3 business days from now = Friday, August 19, 2005
4 business days from now = Monday, August 22, 2005
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55890
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55890&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55890&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55890&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55890&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55890&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55890&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55890&report=yes
Search -- http://master.php.net/manage/user-notes.php