我用过这个:
$date =date(“Y”,strtotime(“-2个月”));
它是"2016-12“,但我需要的是"2016-11”。
发布于 2017-01-31 09:47:38
我用过:
$fdate =date(‘Y’,strtotime(‘-2个月的第一天’);
发布于 2017-01-31 08:47:03
如果您尝试将格式更改为dmY,例如:回显日期(“dmY”,strtotime(“-2个月”));您将看到结果为01122016。
您也可以查看来自此问题的评论:https://stackoverflow.com/questions/10586615/current-date-2-months
您可以在这里检查解决方案:https://stackoverflow.com/questions/9058523/php-date-and-strtotime-return-wrong-months-on-31st
传递第二个参数。
https://drupal.stackexchange.com/questions/227062
复制相似问题