Laravel ORM, date compare

后端 未结 6 1407
情歌与酒
情歌与酒 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:16

    For those who only need to compare a date without time, Lavarel provided a handy function whereDate:

    User::whereDate('created_at', '>=', date('Y-m-d'));
    

    http://laraveldaily.com/eloquent-date-filtering-wheredate-and-other-methods/

提交回复
热议问题