Some times we need to find out how many days in
a certain month. There are two methods to do it. One method is to use
an array to store all the months from January to December. The second
method is very simple by using function date() with option 't'.
How Many Days in a Month - PHP Tutorial
Some times we need to find out how many days in a certain month. There are
two methods to do it.
One method is to use an array to store all the months from January to December.
When you need to know how many days in a certain month, you run a for loop to
check this array to find it out.
The second method is very simple by using function date() with option 't'.
To display how many days of this month, using:
echo date("t");
How many days in last month:
$lastmonth=date("F", strtotime ( "previous month" ));
echo $lastmonth;
How many days in next month:
$nextmonth=date("F", strtotime ( "next month" ));
echo $nextmonth;
|