Re: number of days in a month
| From: | Pavel Jartsev | Date: | Tue, 29 Aug 2000 08:19:55 +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-14068@lists.php.net to get a copy of this message | ||
Jesper Juhl wrote:
>
>
> I couldn't seem to get date() to return the number of days in a month, so
> I handled it like this:
>
> <skip>...
Wow, it's great switch-clause. But maybe 'date()' with 'mktime()' is
simpler.
Like this:
<?
/*---- February 1999 ----*/
$year = 1999;
$month = 2;
$nr_days = date( "t", mktime(0, 0, 0, $month, 1, $year ));
echo "Days in February $year: $nr_days<br>\n";
/*---- August 2000 ----*/
$year = 2000;
$month = 8;
$nr_days = date( "t", mktime(0, 0, 0, $month, 1, $year ));
echo "Days in August $year: $nr_days\n";
?>
Just for fun.
:-)
--
Pavel a.k.a. Papi