Posted By

stefpretty on 09/12/11


Tagged

php function


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

boksiora


Calculate age from DOB


 / Published in: PHP
 

A couple of ideas and options...

  1. function age_from_dob($dob) {
  2. return floor((time() - strtotime($dob)) / 31556926);
  3. }
  4.  
  5.  
  6. function getAge( $p_strDate ) {
  7. list($Y,$m,$d) = explode("-",$p_strDate);
  8. return( date("md") < $m.$d ? date("Y")-$Y-1 : date("Y")-$Y );
  9. }

Report this snippet  

You need to login to post a comment.