Number of days in any given MonthTo get the number of days in a given month we have to use cal_days_in_month function. Syntax is here:
Here is an example
The output is here
Number of days in present monthThere is a better way to get the number of days in present month by using date formats. Here is the code
The output is here
Number of days in next monthWe can read the present month and present year by using date() function. Then we will 1 to present month to get next month and then get the number of days in that month.
The output is here Number of days in 01 month :28You can read more on date format hereNumber of days in previous monthFrom the present month we can subtract 1 to get previous month
This article is written by plus2net.com team.
![]() |
▼ Calendar Functions & Scripts |