On Sat, 2005-08-20 at 00:00, Richard Lynch wrote: > On Thu, August 18, 2005 10:57 pm, benc11@xxxxxxxxx wrote: > > I am trying to add 3 (or a user-defined amount) week days to a certain > > date.. > > An example is today 2005-08-18 then adding 3 week days to give me a > > date of > > 2005-08-23. I have tried searching online but cannot find an easy way > > of > > doing so. > > Assuming you are willing to ignore holidays, which in most real-world > applications, you're not... > > <?php > $certain_date = '8/19/2005'; > $week_days = '...'; > list($m, $d, $y) = explode('/', $certain_date); > $start = mktime(0, 0, 0, $m, $d, $y); > //Every 5 days is a full week: > $weeks = floor($week_days/5); > $close = mktime(0, 0, 0, $m, $d + $weeks * 7, $y); > $remainder = $week_days % 5; > for ($added = 0, $day = 0; $added < $remainder; $day++){ > $dow = date('w', $close + $day*60*60*24); //Is it 'w' for 'day of > week'? > if ($dow == 0 || $dow == 1){ //0|1 are Sun/Sat, right? No, 6 is saturday :B You know, I was looking for which fricking macro expanded to a non locale based indicator for the day of the week yesterday (ala the 'w' for date()). I guess my eyes were getting fuzzy *grin*. Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php