Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get month after and before given month name

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'));
like image 379
RSM Avatar asked Oct 16 '25 17:10

RSM


2 Answers

$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'));
like image 164
Aaron W. Avatar answered Oct 18 '25 06:10

Aaron W.


echo date('F',strtotime('June + 1 month'));
like image 29
Newest Avatar answered Oct 18 '25 05:10

Newest



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!