4

How do I get the month name after a given month. So for June, I would want July

I have tried:

$next_month = date('F',strtotime('June', "next month"));

This display January, which is obviously wrong, I am looking for July.

How would I then get the month before?

I have tried

$prev_month = date('F',strtotime('June - 1 month'));
RSM
  • 14,540
  • 34
  • 97
  • 144

2 Answers2

11
$next_month = date('F',strtotime('June + 1 month'));

or

$next_month = date('F',strtotime('June next month'));

edit

$next_month = date('F',strtotime('June last month'));
Aaron W.
  • 9,254
  • 2
  • 34
  • 45
1
echo date('F',strtotime('June + 1 month'));
Newest
  • 33
  • 3