|
Posted by Richard Lynch on 02/11/05 18:52
Ben C wrote:
> I am trying to add 5 business/week days to today's date. Does anyone
> know a good way of how to do it?
Untested Code:
<?php
//Start with a time-tick NOW:
$now = mktime();
echo "Starting on ", date('l m/d/Y', $now), "<br />\n";
$mdy = date('m/d/Y', $now);
list($m, $d, $y) = explode($mdy);
$workdays = 0;
$then = $now;
while ($workdays < 5){
$then += 60 * 60 * 24; //24 hours, one day
$dow = date('w', $then); //Day Of Week (dow)
if ($dow != 0 && $dow != 6){ //0 Sun ; 6 Sat
$workdays++;
}
}
echo "$workdays away: ", date('l m/d/Y', $then), "<br />\n";
?>
--
Like Music?
http://l-i-e.com/artists.htm
[Back to original message]
|