Reply to Re: [PHP] Adding Business Days

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация