check date between two dates in laravel 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: check if date between two dates laravel eloquent

//get or exist data between two dates
return Set::where('type', $type)
            ->whereDate('active_start', '<=', date("Y-m-d"))
            ->whereDate('active_end', '>=', date("Y-m-d"))
            ->first();
//@sujay

Example 3: how to get dates between two dates in laravel

// how to get dates between two dates in laravel?

//NOTE => for this you can use Carbon
use Carbon\CarbonPeriod;

$period = CarbonPeriod::create("2020-5-20", "2020-5-30");
foreach ($period as $date) {
  // Insert Dates into listOfDates Array
  $listOfDates[] = $date->format('Y-m-d');
}

// Now You Can Review This Array
dd($listOfDates);

Tags:

Php Example