ThinkPHP5查詢昨天數據的方法:1、打開ThinkPHP5相關文件;2、通過表達式“db(‘table’)->whereTime(‘c_time’, ‘yesterday’)->select();”查詢昨天的數據即可。
本教程操作環境:windows7系統、ThinkPHP5版、Dell G3電腦。
ThinkPHP5怎么查詢昨天的數據?
ThinkPHP5 whereTime()使用方法
日期區間查詢
立即學習“PHP免費學習筆記(深入)”;
根據時間戳查詢今天到后天
db('table')->whereTime('time',?'between',?[strtotime(date('Y-m-d')),?strtotime(date('Y-m-d',?strtotime('+2?day')))])->select();
根據日期查詢今天到后天
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();
推薦學習:《thinkPHP視頻教程》
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END