-1

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 ?

Ahmad Badpey
  • 6,348
  • 16
  • 93
  • 159

3 Answers3

4

Try this:

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

Description

Mayank Pandeyz
  • 25,704
  • 4
  • 40
  • 59
1
$question = Question::where('created_at', date("Y-m-d H:i:s",strtotime("22-11-2016"."-1 day")));
Michel
  • 1,065
  • 1
  • 10
  • 25
  • 1
    While this code snippet may solve the question, [including an explanation](//meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. Please also try not to crowd your code with explanatory comments, this reduces the readability of both the code and the explanations! – kayess Nov 22 '16 at 11:07
0
Question::where('created_at', '<', now()->subHours(24));
jaxramus
  • 145
  • 2
  • 6