How to check data between two dates laravel eloquent Code Answer – 2024

In this article, we will learn about how to check data between two dates laravel eloquent

1). check data between two dates laravel eloquent

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

2). check if the date between two dates laravel

Source: itsolutionstuff.com

   //check if date between two dates
$currentDate = date('Y-m-d');
$currentDate = date('Y-m-d', strtotime($currentDate));   
$startDate = date('Y-m-d', strtotime("01/09/2019"));
$endDate = date('Y-m-d', strtotime("01/10/2019"));   
if (($currentDate >= $startDate) && ($currentDate <= $endDate)){   
  echo "Current date is between two dates";
}else{    
  echo "Current date is not between two dates";  
}
//@piyushmaurya

Discover more from STRUGGLER KING.COM

Subscribe now to keep reading and get access to the full archive.

Continue Reading