直接上代码
$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
mac開發接入微信公衆號接口返回報錯 cURL error 56: SSLRead() return error -9806
PHP的換行符是什麽
pecl安裝程序時報錯Array and string offset access syntax with curly braces is no longer supported
由於商家傳入的H5交易參數有誤,該筆交易暫時無法完成,請聯系商家解決