如何在php中显示下个月
我希望输出为如何在php中显示下个月,php,Php,我希望输出为“2018-03-15”; 但是此代码不起作用。您可以使用strotime $date ="2018-02-15"; $next_month = date('$date', strtotime('+1 month'); echo "$next_month"; 结果将是: $date ="2018-02-15"; $time = strtotime($date); $next_month = date("Y-m-d", strtotime("+1 month", $time));
“2018-03-15”
;
但是此代码不起作用。您可以使用
strotime
$date ="2018-02-15";
$next_month = date('$date', strtotime('+1 month');
echo "$next_month";
结果将是:
$date ="2018-02-15";
$time = strtotime($date);
$next_month = date("Y-m-d", strtotime("+1 month", $time));
echo $next_month;
文档:使用以下内容:
2018-03-15
$date ="2018-04-22";
$next_month = date('Y-m-d', strtotime($date.' +1 month'));
echo "$next_month";