Posted By

gummiost on 12/28/12


Tagged

AGE YEARS birthday


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

daK76


Get age in years


 / Published in: PHP
 

This function will get the age in years. It compares the inserted date with the current date and outputs the result.

  1. function get_age($birthday)
  2. {
  3. $birth = strtotime($birthday);
  4. $now = strtotime('now');
  5.  
  6. $age = ($now - $birth) / 31536000;
  7.  
  8. echo floor($age);
  9. }
  10.  
  11. get_age('15 march 1984');

Report this snippet  

You need to login to post a comment.