Re: Calendar math .... how to count in week days....?
| From: | Torsten Roehr | Date: | Thu, 06 May 2004 20:28:30 +0000 |
| Subject: | Re: Calendar math .... how to count in week days....? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-185558@lists.php.net to get a copy of this message | ||
"Anthony" <atampone@attechcomputer.com> wrote in message
news:20040506201839.49569.qmail@pb1.pair.com...
> I've run into a bit of a problem, that I know has been dealt with before,
> but I don't know how to deal with it. Very simple, I have an application
> that needs to do calendar math and do it specifically on business days. I
> need to be able to add and subtract a number of days to only Monday though
> Friday. Seems simple enough, but I can't figure out how to do it. The
only
> think I've come up with so far is to build a function that counts every
day
> and checks to see if it's a weekend or not. This wouldn't be all that
hard
> to do, but I'm wondering if there is a better way to do it? Anyone have a
> really efficient function to do this, I need to figure out a LOT of dates
in
> this app.
>
> - Anthony
Hi Anthony,
take a look at PEAR's Calendar package:
http://pear.php.net/package/Calendar
There is a simple example for building a calendar. Maybe you can adapt it by
ignoring weekends:
http://pear.php.net/manual/en/package.datetime.calendar.intro-inahurry.php
Regards, Torsten