<?

/**
 ** Function which returns a person's age
 ** @param    $d    the birthdate day
 **            $m    the birthdate month
 **            $y    the birthdate year
 **            $h    the birthdate hours, default 0
 **            $i    the birthdate minutes, default 0
 **            $s    the birthdate seconds, default 0
 ** @return int
 **/
function get_age($d$m$y$h 0$i 0$s 0) {
    
$offset 0;

    
// Fix Window's incapability to handle negative timestamps
    
while (($birthdate = @mktime($h$i$s$m$d$y)) < 0) {
        
$offset++;
        
$y++;
    }

    
$date $birthdate;
    
$now mktime(date("h"), date("i"), date("s"), date("m"), date("d"), date("Y") + $offset);
    
$age 0;
    
    
// Continue only when $birthdate < $now
    
if ($birthdate >= $now) return $age;

    
// Count up to the present year
    
while ((date("Y"$now) - 1) > ($year date("Y"$date))) {
        
$date mktime($h$i$s$m$d, ++$year);
        
$age++;
    }
    
    
// Compare $now to the calculated birthdate
    
$age += mktime($h$i$s$m$d, ++$year) < $now;
    return 
$age;
}

print 
get_age(18121966);

?>