i have one date value coming from database and i want to calculate difference between today date and that database date.
the dates coming from database is
2012-06-11 18:20:40
i use this code to see values
echo date('Y-m-d H:i:s');
echo $result['dt_pub_date'];
i have written this code
$val=date('Y-m-d H:i:s') ->diff($result['dt_pub_date']);
but getting this error
Fatal error: Call to a member function diff() on a non-object in.....
Thanks
date()function don’t return DateTime object, just return string.You need to use DateTime object.