Laravel ORM, date compare

后端 未结 6 1545
情歌与酒
情歌与酒 2021-02-03 23:41

I\'m using Laravel Framework.

I want all of the rows for this day. This is what I tried:

DB::table(\'users\')->where(\'created_at\', \'>=\', date(         


        
6条回答
  •  心在旅途
    2021-02-04 00:01

    Simply:

    DB::table('users')->where('created_at', '>=', date('Y-m-d'). ' 00:00:00')
    

    When getting all rows for this day(the time should be 00:00:00), so make sure to set the date condition to current date plus 00:00:00 i.e.

    date('Y-m-d'). ' 00:00:00'
    

提交回复
热议问题