Re: number of days in a month
| From: | Robin Vickery | Date: | Tue, 29 Aug 2000 09:04:39 +0000 |
| Subject: | Re: number of days in a month | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-14074@lists.php.net to get a copy of this message | ||
juhl@eisenstein.dk (Jesper Juhl) writes:
> > Jesper Juhl wrote:
> > >
> > > Hi,
> > >
> > > Is there an easy way in PHP4 to get the number of days in any given
> > > month?
> > > <skip>...
>
> > Hi!
>
> > There is function 'date()', which has a lot of nice formatting
> > possibilities
> > including number of days in given month.
>
> > See chapter 'IX. Date and Time functions' -> 'date()' from PHP
> > manual.
>
> > Hope this helps.
>
>
> > --
> > Pavel a.k.a. Papi
>
> > --
>
> I couldn't seem to get date() to return the number of days in a month, so
> I handled it like this:
> (...)
$month = 1;
$year = 2000;
$days = date( "j", mktime(0, 0, 0, $month + 1, 1, $year) - 1 );
You could also use the function gregoriantojd(int month, int day, int year)
if you the calendar extensions built. I haven't.
-robin
--
Robin Vickery...............................................
Planet-Three, 3A West Point, Warple Way, London, W3 0RG, UK
Email: robin@planet-three.net Phone: +44 (0)870 729 5444