Reputation: 779
I'm currently using the following code to calculate the next month:
$nextMonth = date("m",strtotime("+1 months"));
If the current date is March 31 (03), this code gives me "05" which is actually 2 months away from the current date. I would like it to return April (04) instead.
How can I achieve this?
Upvotes: 0
Views: 453
Reputation: 3105
how about trying this:
$d = new DateTime(date("Y-m-d"));
$d->modify( 'first day of next month' );
echo $d->format( 'F' ), "\n";
Dins
Upvotes: 1