note 51968 added to function.date
| From: | christian at maxnamara dot com | Date: | Sun, 17 Apr 2005 10:35:04 +0000 |
| Subject: | note 51968 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-88105@lists.php.net to get a copy of this message | ||
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;
?>
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51968
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51968&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51968&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51968&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51968&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51968&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51968&report=yes
Search -- http://master.php.net/manage/user-notes.php