Photo : Dafne Cholet
Ever wonder how many days there are in a specific month ?
Your quest is over, I have what you need : the cal_days_in_month() function from the Calendar PHP extension. This function can work with different calendars : gregorian, julian, jewish… Then just specified a month of a particular year and it will return the number of days :
$days = cal_days_in_month(CAL_GREGORIAN, 2, 2024);
echo $days; // output : 29
$days = cal_days_in_month(CAL_GREGORIAN, date('n'), date('Y'));
echo $days; // output : 30
To list the available calendars, you may use cal_info() :
print_r(cal_info());
See “sources” links for more informations
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
Sources :