note 43107 deleted from function.checkdate by tomsommer
| From: | tomsommer@php.net | Date: | Wed, 09 Jun 2004 21:47:42 +0000 |
| Subject: | note 43107 deleted from function.checkdate by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-70604@lists.php.net to get a copy of this message | ||
Note Submitter: John Dough
----
Since no month (to my knowledge) has less than 28 days start counting from 28 instead of 0. Might
save a little time.
Or just quit calculating things that you already know:
function last_day_of_month( $month, $year ){
if($month==2){
if( checkdate(2, 29, $year) ) return 29;
else return 28;
}else{
switch($month){
case 1: return 31;
case 3: return 31;
case 4: return 30;
case 5: return 31;
case 6: return 30;
case 7: return 31;
case 8: return 31;
case 9: return 30;
case 10: return 31;
case 11: return 30;
case 12: return 31;
}
}
}