Search code examples
phplaravelphp-carbon

select models that more than 24 hours have passed since their creation in laravel


I think that question title is Self-Descriptive.

In fact I want to select all rows that more than 24 have passed since their created_at attribute in laravel with Carbon and where clauses.

$question = Question::where('created_at',/* what do I here*/);

How can I do that ?


Solution

  • Try this:

    $question = Question::where('created_at', '>=', Carbon::now()->subDay())->get();
    

    Description