本文由 源码库 – 管理员 发布,转载请注明出处,如有问题请联系我们!ThinkPHP5怎么查询昨天的数据
加入收藏ThinkPHP5查询昨天数据的方法:1、打开ThinkPHP5相关文件;2、通过表达式“db('table')->whereTime('c_time', 'yesterday')->select();”查询昨天的数据即可。

ThinkPHP5怎么查询昨天的数据?ThinkPHP5 whereTime()使用方法
根据日期查询今天到后天db('table')->whereTime('time', 'between', ['2020-3-28', '2020-3-30'])->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怎么查询昨天的数据?ThinkPHP5 whereTime()使用方法
日期区间查询
根据时间戳查询今天到后天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();
评论(0条)
