Laravel ORM, date compare

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

    I know that topic is old but may someone try to find a solution from search engines.

    You can use:

    User::whereDate('created_at', '=', Carbon::today()->toDateString());
    

    You can visit this link if you want to know more about date comparison in Laravel using where.

    Eloquent date filtering: whereDate() and other methods

提交回复
热议问题