Rob, I tried your code below, but it didn't work. I put the number of week days in $addWeekdays variable. Am I doing something wrong or is there an error in the code? Appreciate your help! On 8/18/05, Robert Cummings <robert@xxxxxxxxxxxxx> wrote: > > On Fri, 2005-08-19 at 02:17, Robert Cummings wrote: > > This doesn't work since the value can be user defined and thus may span > > multiple weeks :) The following works but is dirty, I'm sure there's a > > better solution using modulus operator and adding and subtracting and a > > little voodoo... I'm just too lazy atm to think it up ;) > > Ok so I felt like doing it :) > > <?php > > // > // For every 5 days to add we wrap a week and are right back where we > // started so... > // > > $addWeekdays = isset( $argv[1] ) ? $argv[1] : 0; // command line for fun > $start = time(); > > $addWeeks = (int)($addWeekdays / 5); > $addWeekDays = ($addWeekdays % 5); > > $daySeconds = (24 * 60 * 60); > > $final = $start + ($addWeeks * 7 * $daySeconds); > while( $addWeekDays > 0 ) > { > $final += $daySeconds; > > $day = date( 'D', $final ); > if( $day != 'Sat' && $day != 'Sun' ) > { > $addWeekDays--; > } > } > > echo 'Start: '.date( 'Y-m-d (D)', $start )."\n"; > echo 'Final: '.date( 'Y-m-d (D)', $final )."\n"; > > > -- > .------------------------------------------------------------. > | 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 > >