Getting all the days in a month

is there a function to find out how many days are in a month?
I saw a few on but I needed some sort of mcal plugin or something… is there one built right into the language?

Use a combination of date and mktime:


function daysInMonth($year, $month) {
    return date("t", mktime (0,0,0,$month,1,$year));

$year  = "2002";
$month = "3";    // March

echo "Days in $month/$year: ". daysInMonth($year, $month);




This returns the number of days in the current month.

So by using scoates’ method you can get the # of days of any given month.