This simple function will return number of days for given month in php
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);
}

Example:
echo days_in_month(2,2015); # outputs 28

 


Comments (0)
Leave a Comment

loader Posting your comment...