Here is an another approach.. if you glance at a calendar, youll notice that
the only times there are 5 sats in a month, is when the 1st of 30 day month
falls on a fri or sat.. or in a 31 day month, a thur, fri, or say..
So, you could simply test the weekday the first of the month has, and the
Sorry, I made a mistake. See below:
""Brian P. O'Donnell"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> ""Shaun"" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Hi,
> >
> > Is it possible to get the number of saturdays and sundays for a given
> month
> > / year
""Shaun"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
> Is it possible to get the number of saturdays and sundays for a given
month
> / year?
>
> Thanks for your help.
Here's another way to do it. Each function will return either 4 or 5. If you
need both Saturdays and Sund
since only the total number of saturdays/sundays is what he wants to
know, you can use some clever math. Basically, the amount of saturdays
in a year is:
floor(365 (+1 if it's a leap year) (-days from january first to first
saturday) / 7);
and sundays = saturdays (-1 if the modulo from the top
the answer is simply yes!
You can have a simple for looping to do so.
hope this help!
""Shaun"" <[EMAIL PROTECTED]>
wrote:[EMAIL PROTECTED]
> Hi,
>
> Is it possible to get the number of saturdays and sundays for a given
> month / year?
>
> Thanks for your help.
--
PHP General Mailing List
5 matches
Mail list logo