$date = Carbon::now(); // suppose Current month is May
$lastMonth = $date->subMonth()->format('F'); // returns April
$nextMonth = $date->addMonth()->format('F'); // returns June
上面的代码运行良好。但我有一个函数需要传递月份名称:
$month = "Feburary"; // it can be any random month
function getNextMonth($month)
{
//$date = Carbon::now();
return $date->addMonth()->format('F'); // need the output to be March
}