Re: Week Days

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2005-08-19 at 13:47, Philip Hallstrom wrote:
> >> All you need is the mktime() command.
> >>
> >> do something like:
> >> $futureDate = date("Y-m-d", mktime(0, 0, 0, $month, $today+
> >> $daysToAdd, $year));
> >>
> >> Jordan
> >>
> >>
> >> http://www.php.net/mktime
> >> mktime() is useful for doing date arithmetic and validation, as it
> >> will automatically calculate the correct value for out-of-range
> >> input. For example, each of the following lines produces the string
> >> "Jan-01-1998".
> >>
> >> <?php
> >> echo date("M-d-Y", mktime(0, 0, 0, 12, 32, 1997));
> >> echo date("M-d-Y", mktime(0, 0, 0, 13, 1, 1997));
> >> echo date("M-d-Y", mktime(0, 0, 0, 1, 1, 1998));
> >> echo date("M-d-Y", mktime(0, 0, 0, 1, 1, 98));
> >> ?>
> >
> > All fine and dandy... but he said WEEKDAYS, so adding 5 days to a given
> > day must non deduct from the 5 days when a weekend day is passed. This
> > kind of calculation is useful for banks and other businesses that only
> > process transactions on business days (which happen to be weekdays).
> 
> Easy enough to change that date(...mktime(...)) command above to return 
> the weekday and while the weekday is a weekend just add a day and repeat

Well of course.. I already posted a full solution last night :) One
using the technique you describe above, which is a bad solution since it
requires the loop to run once for each day to add, and then another
solution which divides the problem into two subproblems which is MUCH
faster on larger sets of days to add.

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux