Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Aleksandar-Mitic/440bc5fdb0e3df56cbbf93ddee06aee9 to your computer and use it in GitHub Desktop.
Save Aleksandar-Mitic/440bc5fdb0e3df56cbbf93ddee06aee9 to your computer and use it in GitHub Desktop.
PHP function that returns the exact age
function age($month, $day, $year){
$y = gmstrftime("%Y");
$m = gmstrftime("%m");
$d = gmstrftime("%d");
$age = $y - $year;
if($m <= $month)
{
if($m == $month)
{
if($d < $day) $age = $age - 1;
}
else $age = $age - 1;
}
return($age);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment