How can I print (echo) the days of an unknown month if month and year are parameters?
Thank you.
To get the number of days in a given month of a given year you can use cal_days_in_month
echo cal_days_in_month(CAL_GREGORIAN, 10, 2010); // prints 31
You can also use the date() function to get the number of days in a month. You can also pass the 2nd param strtotime() and specify a specific date:
$daysInMon = date('t', mktime(0, 0, 0, $month));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With