I need to find the difference between 2 dates from an array. Here is the array:
$lists[] = date('Y-m-d', strtotime($user->created_at));
Example output of echo $lists[1];
is 2017-08-01
I have tried
$difftime = $lists[1]->diff($lists[0]);
echo $difftime->format('d');
and echo $lists[1]->diff($lists[0]);
Both giving me error:
Call to a member function diff() on string
I have also tried echo date_diff($lists[1], $lists[0]);
It's giving error
date_diff() expects parameter 1 to be DateTimeInterface, string given
I know there are many questions on same issue here, but I could not find a solution that works for me. So please help me.