note 51968 deleted from function.date by victor
| From: | victor@php.net | Date: | Sun, 17 Apr 2005 14:05:24 +0000 |
| Subject: | note 51968 deleted from function.date by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-88120@lists.php.net to get a copy of this message | ||
Note Submitter: christian at maxnamara dot com
Reason: useless
----
Here is my code to get the date end of each month.
<?
function days_in_feb($year) {
if ($year < 0) {
$year++;
}
$year += 4800;
if ( ($year % 4) == 0) {
if (($year % 100) == 0) {
if (($year % 400) == 0) {
return(29);
} else {
return(28);
}
} else {
return(29);
}
} else {
return(28);
}
}
function end_of_month($month, $year) {
$year = intval($year);
$feb = days_in_feb($year);
$end_dates = array('01'=>'31',
'02'=> $feb,
'03'=>'31',
'04'=>'30',
'05'=>'31',
'06'=>'30',
'07'=>'31',
'08'=>'31',
'09'=>'30',
'10'=>'31',
'11'=>'30',
'12'=>'31');
while (list($month_num,$date) = each($end_dates)) {
if($month_num == $month) {
$my_end_date = $date;
}
}
$eom = $my_end_date;
return($eom);
}
$a = end_of_month('04', '2005');
echo $a;
?>