$today= new DateTime(date('Y-m-d'));
$dob= new DateTime($user_dob);
$diff = $today->diff($dob);
return $diff->y .' Year';
I am trying to calculate age but its showing error Call to undefined method DateTime::diff()
how can i solve this problem? i m using PHP Version 5.4.24