note 45045 deleted from function.cal-days-in-month by tularis
| From: | tularis@php.net | Date: | Tue, 01 May 2007 14:48:14 +0000 |
| Subject: | note 45045 deleted from function.cal-days-in-month by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-126088@lists.php.net to get a copy of this message | ||
Note Submitter: richard at N O S P A M dot computoz dot co dot uk
----
re: rshowalter at mtsinai dot on dot ca 's daysinmonth.
This is faster (no loop, no testing irrelevant values):
function daysinmonth($month, $year)
{
if(checkdate($month, 31, $year)) return 31;
if(checkdate($month, 30, $year)) return 30;
if(checkdate($month, 29, $year)) return 29;
if(checkdate($month, 28, $year)) return 28;
return 0; // error
}
and won't inf-loop on you, ever.