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

The easiest way:

$from = '2014-08-10 09:30:00';
$till = '2014-08-10 11:00:00';

$collection = Model::whereBetween('your_field', [$from, $till])->get();

Adjust it to the date format you use. Utilize Carbon if you like.

Last updated 2 years ago.
0

Thank you! That worked as a charm for periods of time, but I reckon that it doesn't for cases like "get me all the things in the database from June to July between 09:00 and 11:00 every day".

In that case should you perform some database specific functions or is it a nicer way to tackle this? Thank you.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Terumi terumi Joined 13 Feb 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.