溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

ThinkPHP5如何查詢昨天的數(shù)據(jù)

發(fā)布時間:2022-12-05 09:33:53 來源:億速云 閱讀:233 作者:iii 欄目:編程語言

今天小編給大家分享一下ThinkPHP5如何查詢昨天的數(shù)據(jù)的相關(guān)知識點,內(nèi)容詳細,邏輯清晰,相信大部分人都還太了解這方面的知識,所以分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后有所收獲,下面我們一起來了解一下吧。

ThinkPHP5查詢昨天數(shù)據(jù)的方法:1、打開ThinkPHP5相關(guān)文件;2、通過表達式“db('table')->whereTime('c_time', 'yesterday')->select();”查詢昨天的數(shù)據(jù)即可。

ThinkPHP5 whereTime()使用方法

日期區(qū)間查詢

根據(jù)時間戳查詢今天到后天

db('table')->whereTime('time', 'between', [strtotime(date('Y-m-d')), strtotime(date('Y-m-d', strtotime('+2 day')))])->select();

根據(jù)日期查詢今天到后天

db('table')->whereTime('time', 'between', ['2020-3-28', '2020-3-30'])->select();

表達式查詢

獲取今天的信息

db('table')->whereTime('c_time', 'today')->select();
//也可以簡化為下面方式
db('table')->whereTime('c_time', 'd')->select();

獲取昨天的信息

db('table')->whereTime('c_time', 'yesterday')->select();

獲取本周的信息

db('table')->whereTime('c_time', 'week')->select();   
//也可以簡化為下面方式
db('table')->whereTime('c_time', 'w')->select();

獲取上周的信息

db('table')->whereTime('c_time', 'last week')->select();

獲取本月的信息

db('table')->whereTime('c_time', 'month')->select();   
//也可以簡化為下面方式
db('table')->whereTime('c_time', 'm')->select();

獲取上月的信息

db('table')->whereTime('c_time','last month')->select();

獲取今年的信息

db('table')->whereTime('c_time', 'year')->select();    
//也可以簡化為下面方式
db('table')->whereTime('c_time', 'y')->select();
獲取去年的信息
db('table')->whereTime('c_time','last year')->select();

以上就是“ThinkPHP5如何查詢昨天的數(shù)據(jù)”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家閱讀完這篇文章都有很大的收獲,小編每天都會為大家更新不同的知識,如果還想學(xué)習(xí)更多的知識,請關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI