直接上代码
$date_you_want = match ($condition) { '昨天' => date("Y-m-d", strtotime("-7 days", time())), '上月' => date("Y-m-d", strtotime("-1 months", time())), '去年' => date("Y-m-d", strtotime("-1 years", time())), };
如果想算下一天/月/年的, 就把-1改成+1, 以此类推。
php在date函数的库里加入了非常简单的追算上一段固定时间周期的写法。
直接上代码
$date_you_want = match ($condition) { '昨天' => date("Y-m-d", strtotime("-7 days", time())), '上月' => date("Y-m-d", strtotime("-1 months", time())), '去年' => date("Y-m-d", strtotime("-1 years", time())), };
如果想算下一天/月/年的, 就把-1改成+1, 以此类推。
有用
423
没用
29
开心
77
愤怒
7
可怜
26
1.如文章侵犯了您的版权,请发邮件通知本站,该文章将在24小时内删除;
2.本站标注原创的文章,转发时烦请注明来源;
3.Q群: 2702237 13835667
mac开发接入微信公众号接口返回报错 cURL error 56: SSLRead() return error -9806
pecl安装程序时报错Array and string offset access syntax with curly braces is no longer supported
PHP的换行符是什么
由于商家传入的H5交易参数有误,该笔交易暂时无法完成,请联系商家解决