I have a date array and I want to retrieve those that are an interval.
For example: Retrieve me those with a date between 2023-03-01 and 2023-03-31
My collection is presented :
{
"departures": [
"2022-10-23T23:30:00.000+00:00", // Date object
"2023-02-02T23:30:00.000+00:00",
"2023-11-10T18:00:00.000+00:00"
],
"price": 310,
}
$beginDate = Carbon::createFromFormat("Y-m-d", "2023-03-01");
$endDate = clone $beginDate;
$endDate->endOfMonth();
$search->whereBetween('departures', [$beginDate->toDateTime(), $endDate->toDateTime()])->get()->toArray();
I expect him to show me a blank array, but it returns me all the collection.
I think the problem is that I am using a date array. I would have to be able to filter anyway.
Thanks