How to get the next month in PHP

Use Like This

// One month from today
$date = date('Y-m-d', strtotime('+1 month'));

// One month from a specific date
$date = date('Y-m-d', strtotime('+1 month', strtotime('2015-01-01')));

If you want to get the next irrespective of the current date in the current month. below code may help you

echo date('M',strtotime('first day of +1 month'));
// e.g. "Jan"

echo date('m',strtotime('first day of +1 month'));
// e.g. "1"

echo date('F',strtotime('first day of +1 month'));
// e.g. "January"

This will give you Next month.

You can find more formatting masks in date() function documentation


To get next month using php use string to time function as below:

$nxtm = strtotime("next month");
echo date("M", $nxtm);

Tags:

Php