Log in

View Full Version : Resolved Determining days in any given month



hosdank
05-14-2009, 02:54 PM
Is there a PHP function to give me the days in any given month? For example let's say I want to know how many days are in February for this year. The function will return the number of days that are in February; 28 normally, 28 if it's a leap year.

Thanks :)

Schmoopy
05-14-2009, 02:58 PM
Yes indeedy there is:


echo cal_days_in_month(CAL_GREGORIAN, 5, 2009);

First parameter is the calendar type, gregorian is standard.

Then 5 is the month (May), then the year.

This will return the amount of days in that month for that year: 31.

hosdank
05-14-2009, 03:13 PM
Thanks :)