laravel query between dates code example
Example 1: laravel between dates
$from = date('2018-01-01');
$to = date('2018-05-02');
Reservation::whereBetween('reservation_from', [$from, $to])->get();
Example 2: laravel date between
$from = date('2018-01-01');
$to = date('2018-05-02');
Reservation::whereBetween('reservation_from', [$from, $to])->get();
Example 3: how to get dates between two dates in laravel
use Carbon\CarbonPeriod;
$period = CarbonPeriod::create("2020-5-20", "2020-5-30");
foreach ($period as $date) {
$listOfDates[] = $date->format('Y-m-d');
}
dd($listOfDates);