从出生日期计算年龄

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从出生日期计算年龄相关的知识,希望对你有一定的参考价值。

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. }

以上是关于从出生日期计算年龄的主要内容,如果未能解决你的问题,请参考以下文章