Created
May 24, 2011 15:47
-
-
Save jameserie/988956 to your computer and use it in GitHub Desktop.
Calculate persons age using date of birth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function age($date){ | |
list($year,$month,$day) = explode("-",$date); | |
$year_diff = date("Y") - $year; | |
$month_diff = date("m") - $month; | |
$day_diff = date("d") - $day; | |
if ($day_diff < 0 || $month_diff < 0) $year_diff--; | |
return $year_diff; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment