可能重复:
php中给定月份的下个月和上个月
我用这个代码:
$prev_month = strtolower(date('F',strtotime('February - 1 month')));
Run Code Online (Sandbox Code Playgroud)
并且总是返回12月,即使我将月份更改为3月.
请帮忙!
MrC*_*ode 13
$currentMonth = date('F');
echo Date('F', strtotime($currentMonth . " last month"));
Run Code Online (Sandbox Code Playgroud)
如果您不希望它相对于当前月份,则设置:
$currentMonth = 'February';
// outputs January
Run Code Online (Sandbox Code Playgroud)