PHP Strtotime -1个月-2个月 [英] PHP Strtotime -1month -2month

查看:313
本文介绍了PHP Strtotime -1个月-2个月的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

昨天运行良好,没有更改代码.

This was working fine yesterday with no changes to the code.

echo date("M", strtotime("-3 month", time()) );
echo date("M", strtotime("-2 month", time()) );
echo date("M", strtotime("-1 month", time()) );
echo date("M", time());

它昨天产生的输出符合您的预期-即4月,5月,6月,7月

The output it was producing yesterday was as you would expect- i.e. Apr, May, Jun, Jul

今天它回响着五月五月七月七月

Today it echoes May May Jul Jul

有什么想法吗?

谢谢.

推荐答案

它可能与错误您可以尝试这样的事情:

You could try with something like this :

echo date("M", strtotime("-3 month", strtotime(date("F") . "1")) ) . "\n";
echo date("M", strtotime("-2 month", strtotime(date("F") . "1")) ) . "\n";
echo date("M", strtotime("-1 month", strtotime(date("F") . "1")) ) . "\n";
echo date("M", time()) . "\n";

(解决方案可在 strtotime 的注释部分中找到; 输出:

Apr
May
Jun
Jul

带有日期格式和月份名称以及所有其他内容的作弊"种类...

这篇关于PHP Strtotime -1个月-2个月的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆