On Mar 10, 2012, at 12:20 PM, Maciek Sokolewicz wrote:
> function getAmountOfDaysInAMonth($month, $year) {
> $days = array(31, (($year%4==0 and ($year%100 > 0 or $year%400==0)) ? 29 :
> 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
> return $days[$month+1];
> }
I like that -- here's a small variation.
function numberDaysMonth($month, $year)
{
// Leap year is definded as a year that is evenly divisible by four
// AND (year NOT evenly divisible by 100 OR year IS evenly divisible by
400)
$feb = ($year%4 == 0 && ($year%100 != 0 || $year%400 == 0) ) ? 29 : 28;
$days = array(0, 31, $feb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
return $days[$month];
}
Cheers,
tedd
_____________________
[email protected]
http://sperling.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php