If you wish a function to calculate age of a person/car or whatever you want you have come to the right place. The following function will calculate age from a specific date. The date must be in a accepted format for the function strtotime.

function ageold($date){
    $time = strtotime($date);
    if($time === false){
      return '';
    }
 
    $year_diff = '';
    $date = date('Y-m-d', $time);
    list($year,$month,$day) = explode('-',$date);
    $year_diff = date('Y') - $year;
    $month_diff = date('m') - $month;
    $day_diff = date('d') - $day;
    if ($day_diff < 0 || $month_diff < 0) $year_diff-;
 
    return $year_diff;
}8

 

You might find interesting:   Convert minutes to hours and minutes or seconds to minutes and seconds

NO COMMENTS

LEAVE A REPLY