Calculators
|
|
|
|
<?
/* I wrote this snippet to combat the limitations of the mktime function due to the beginning of the Unix Epoch. */
function calculate_age($birth_day, $birth_month, $birth_year) {
$datestamp = date("d.m.Y", mktime());
$t_arr = explode("." , $datestamp);
$current_day = $t_arr[0];
$current_month = $t_arr[1];
$current_year = $t_arr[2];
$year_dif = $current_year - $birth_year;
if(($birth_month > $current_month) || ($birth_month == $current_month && $current_day < $birth_day))
$age = $year_dif - 1;
else
$age = $year_dif;
return $age;
}
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|