I’am getting this "Call to a member function modify() on string"
$date = $request->start_date;
$start_date = date('d-m-Y',strtotime($date));
$e_date = $request->end_date;
$end_date = date('d-m-Y',strtotime($e_date));
$data = [];
for($i = $start_date; $i <= $end_date; $i->modify('+1 day')) {
$data[] = $i;
}
return $data;
>Solution :
I would suggest to use Carbon for this.
use Carbon\Carbon;
$start_date = new Carbon(strtotime('2022-01-06'));
$end_date = new Carbon(strtotime('2022-01-08'));
$data = [];
for ($i = $start_date; $i <= $end_date; $i->addDays(1)) {
$data[] = $i;
}
return $data;
I hope it works for your situation! 🙂