Age calculation in php

From Code Trash
Jump to: navigation, search
function age_calculation($day,$month,$year)
{
     $ageTime = mktime(0, 0, 0, $month, $day, $year); // Get the person's birthday timestamp
     $t = time(); // Store current time for consistency
     $age = ($ageTime < 0) ? ( $t + ($ageTime * -1) ) : $t - $ageTime;
     $year = 60 * 60 * 24 * 365;
     $ageYears = $age / $year;
 
     return floor($ageYears);
}