whereTime('c_time', 'yesterday')->select();" Can."/> whereTime('c_time', 'yesterday')->select();" Can.">

Home>Article>PHP Framework> How to query yesterday's data in ThinkPHP5

How to query yesterday's data in ThinkPHP5

藏色散人
藏色散人 Original
2022-12-05 09:20:48 1691browse

How to query yesterday's data in ThinkPHP5: 1. Open ThinkPHP5 related files; 2. Use the expression "db('table')->whereTime('c_time', 'yesterday')->select( );" Just query yesterday's data.

How to query yesterday's data in ThinkPHP5

The operating environment of this tutorial: Windows 7 system, ThinkPHP version 5, Dell G3 computer.

How to query yesterday’s data in ThinkPHP5?

ThinkPHP5 whereTime() usage method

Date interval query

Query today to the day after tomorrow based on timestamp

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

Query today to the day after tomorrow based on date

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

Expression query

Get today’s information

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

Get yesterday’s information

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

Get this week’s information

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

Get last week's information

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

Get this month's information

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

Get last month's information

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

Get this year's information

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

Recommended learning: "thinkPHP Video Tutorial"

The above is the detailed content of How to query yesterday's data in ThinkPHP5. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn