Laravel ORM, date compare

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

    Hmmm...there was a good answer to this question which seems to have now disappeared.*

    It was something like this:

    User::where('created_at', '>=', new DateTime('today'))
    

    Note: if you're putting this code in a file with a namespace, or might use a namespace in the future, you should prefix the DateTime class with a backslash: new \DateTime('today').

    * https://stackoverflow.com/questions/15052679/laravel-framework-how-to-get-today-queries

提交回复
热议问题