note 45045 added to function.cal-days-in-month
| From: | richard at NOSPAM dot computoz dot co dot uk | Date: | Tue, 24 Aug 2004 12:55:08 +0000 |
| Subject: | note 45045 added to function.cal-days-in-month | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-75195@lists.php.net to get a copy of this message | ||
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.
----
Manual Page -- http://www.php.net/manual/en/function.cal-days-in-month.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45045
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45045&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45045&report=yes
Search -- http://master.php.net/manage/user-notes.php