Simple Days in Month function

by Guna 2011-03-11 14:51:43

Hi,

Simply pass the month,years in numbers it will return return number of days in that month.

function days_in_month($month, $year) {
//calculate number of days in a month
//$month: numeric month (integers 1-12)
//$year: numeric year (any integer)
return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
}

Tagged in:

1005
like
0
dislike
0
mail
flag

You must LOGIN to add comments