View Single Post
Old 08-13-2008, 01:47 PM   #2 (permalink)
buggabill
The Contributor
 
buggabill's Avatar
 
Join Date: Jan 2008
Location: Maine, USA
Posts: 92
Thanks: 2
buggabill is on a distinguished road
Default

The Unix epoch which mktime uses starts on January 1, 1970. Wikipedia Article

Someone born in 1970 would be 38 today.

You will need to some modifications to that script to get accurate ages before that date.

You could do something like the following:
php Code:
<?php
function calculate_age ($month, $day, $year) {
    $year_diff = date("Y") - ($year);
    $month_diff = date("m") - ($month);
    $day_diff = date("d") - ($day);
   
    if ($month_diff < 0) {
        $year_diff--;
    }
    elseif ($month_diff == 0 && $day_diff < 0) {
        $year_diff--;
    }

    return $year_diff;
}
?>
__________________
-- Bill
"Why is it drug addicts and computer aficionados are both called users?" -Clifford Stoll
buggabill is offline  
Reply With Quote