【发布时间】:2017-03-30 06:30:56
【问题描述】:
我在我的项目中使用了 php strtotime 函数,它工作正常,但是今天有用户报告了一个问题,我检查并发现 strtotime 函数没有给出正确的输出。 我的代码是:
echo date('M Y', strtotime('-1 month'));
它正在输出:
Mar 2017 instead of Feb 2017
我在代码在线工具上检查了上面的代码,它在那里给出了相同的输出,那么是 php 核心功能问题还是我犯了一些错误? 注意:我在网上查了以下代码
echo date('Y-m-d', strtotime('-1 month'));
它的输出让我很奇怪
2017-03-02
【问题讨论】:
-
使用这个日期("MY", strtotime("-1 month", strtotime(date("F") . "1")) );