i am trying to find difference between two dates in php, the first date is coming from my database (which is in datetime format), so i am converting it to date and then finding the difference using the current date. my code is like below:
$ret=mysqli_query($con,"select * from members");
$cnt=1;
while ($row=mysqli_fetch_array($ret))
{
$date_time = $row['date'];
$new_date = date("Y-m-d",strtotime($date_time));
$dates = date('Y-m-d');
$diff = $new_date->diff($dates);
echo $diff;
}
then i am getting the following error:
Uncaught Error: Call to a member function diff() on string in C:\xampp\htdocs\form\admin\members.php:123 Stack trace: #0 {main} thrown in C:\xampp\htdocs\form\admin\members.php on line 123
can anyone please tell me what i am doing here is wrong. thanks in advance