Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function calculateAge($birthdate){
- $curYear = date("Y");
- $curMonth = date("m");
- $curDay = date("d");
- $userYear = substr($birthdate, 0, 4);
- $userMonth = substr($birthdate, 4, 2);
- $userDay = substr($birthdate, 6, 2);
- $age = $curYear - $userYear - 1;
- if($curMonth >= $userMonth) {
- if($curDay >= $userDay) {$age++;}
- }
- return $age;
- }
Add Comment
Please, Sign In to add comment