Support the ongoing development of Laravel.io →
Database Eloquent Forms
Last updated 2 years ago.
0

Since Laravel uses brilliant Carbon class for handle dates it's as easy as this:

// consider created_at is the field you want to query on the model called News
$date = new Carbon\Carbon; //  DateTime string will be 2014-04-03 13:57:34

$date->subWeek(); // or $date->subDays(7),  2014-03-27 13:58:25

News::where('created_at', '>', $date->toDateTimeString() )->get();
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Failcookie failcookie Joined 20 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.