Created
April 4, 2017 10:18
-
-
Save Aleksandar-Mitic/440bc5fdb0e3df56cbbf93ddee06aee9 to your computer and use it in GitHub Desktop.
PHP function that returns the exact age
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($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