note 24390 added to function.date
| From: | patriko2k at yahoo dot com | Date: | Thu, 15 Aug 2002 01:31:17 +0000 |
| Subject: | note 24390 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-35047@lists.php.net to get a copy of this message | ||
Here is a quick little script I made up to find the number of days in a given month (in the given
year). Please tell me if you find any mistakes in it, but to me it seems like it works well:
function numDays($month,$year)
{
// Returns the number of days in a $month, in the given $year.
// Checks for a leap year.
if ((!strstr($year/4,"."))&&(substr(2,4,$year)!=00)){
$leapyear = 1;}
if(substr(2,4,$year)==00){
if(!strstr($year/400,".")){
$leapyear = 1;}
}
switch($month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
$total_days = 31;
break;
case 4:
case 6:
case 9:
case 11:
$total_days = 30;
break;
case 2:
if ($leapyear)
{
$total_days = 29;
}
else
{
$total_days = 28;
}
break;
default:
break;
}
return $total_days;
}
--
http://www.php.net/manual/en/function.date.php
http://master.php.net/manage/user-notes.php?action=edit+24390
http://master.php.net/manage/user-notes.php?action=delete+24390
http://master.php.net/manage/user-notes.php?action=reject+24390