Guest User

Untitled

a guest
May 22nd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. function calculateAge($birthdate){
  2. $curYear = date("Y");
  3. $curMonth = date("m");
  4. $curDay = date("d");
  5.  
  6. $userYear = substr($birthdate, 0, 4);
  7. $userMonth = substr($birthdate, 4, 2);
  8. $userDay = substr($birthdate, 6, 2);
  9. $age = $curYear - $userYear - 1;
  10.  
  11. if($curMonth >= $userMonth) {
  12. if($curDay >= $userDay) {$age++;}
  13. }
  14. return $age;
  15. }
Add Comment
Please, Sign In to add comment