In this article, you will learn how to get the number of days in the month of a certain year. The cal_days_in_month() function returns the number of days of the given month and the given year of the calendar.
What is the syntax of the cal_days_in_month() function in PHP?
cal_days_in_month(calendar,month,year);
Parameters | Details |
---|---|
calendar | The calendar to follow – Required |
month | The month (numeric number) – Required |
year | The specific year to consider the month in – Required |
Examples of cal_days_in_month() function
Example 1. Get the number of days for the specified month, year and calendar.
<?php
$days=cal_days_in_month(CAL_GREGORIAN,01,2021);
echo "Days in January 2021: " $days;
?>