Calculate Age using PHP (mounth-day-year to age)


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. # mounth-day-year
  2. function getAge($date){
  3. $bday = explode("-", $date, 3);
  4. $bday = mktime(0,0,0,$bday[0],$bday[1],$bday[2]);
  5. $age = (int)((time()-$bday)/31556926 );
  6. return $age;
  7. }
  8.  
  9. #eg:
  10. echo getage("03-27-1990"); # returns the age.

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.