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

Found it:

Model::whereBetween('created_at', array(Carbon\Carbon::createFromDate(2010, 1, 1)->toDateTimeString(), Carbon\Carbon::createFromDate(2012, 1, 1)->toDateTimeString()))->get();
Last updated 2 years ago.
0

This example uses Brazilian date format (d/m/Y).

$model = Model::with(['access'])
    ->select(['id','title','slug','created_at','status'])
    ->withTrashed();

$from = Carbon::createFromFormat('d/m/Y', Input::get('date'))
    ->startOfDay()
    ->toDateTimeString();

$to = Carbon::createFromFormat('d/m/Y', Input::get('date'))
    ->endOfDay()
    ->toDateTimeString();

$model = $model->whereBetween('created_at', [$from, $to]);
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.