PHP repeats for the month of the month, month, and year

How can I print (echo) the days of an unknown month if the month and year are parameters?

Thank.

+3
source share
2 answers

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
+4
source

You can also use the date () function to get the number of days per month. You can also pass the 2nd parameter to strtotime () and specify a specific date:

$daysInMon = date('t', mktime(0, 0, 0, $month));
+2
source

Source: https://habr.com/ru/post/1768463/


All Articles