TP---时间查询(当日、本周、本月、本年)

1、按照日期查询类似于当日、本周、本月、本年的数据

// 获取当日的数据
Db::table('table') ->whereTime('times', 'today')->select();
// 获取昨天的数据
Db::table('table')->whereTime('times', 'yesterday')->select();
// 获取本周的数据
Db::table('table')->whereTime('times', 'week')->select();   
// 获取上周的数据
Db::table('table')->whereTime('times', 'last week')->select();    
// 获取本月的数据
Db::table('table')->whereTime('times', 'month')->select();   
// 获取上月的数据
Db::table('table')->whereTime('times', 'last month')->select();      
// 获取今年的数据
Db::table('table')->whereTime('times', 'year')->select();    
// 获取去年的数据
Db::table('table')->whereTime('times', 'last year')->select();  

其他相关查询:https://blog.csdn.net/qq_42455095/article/details/84935193

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章