Calculate age from DOB


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

A couple of ideas and options...


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.