• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

ThinkPHP5查看询昨天的数据

武飞扬头像
PHP中文网
帮助114

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();

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanffghi
系列文章
更多 icon
同类精品
更多 icon
继续加载