PHP calculate person's current age

后端 未结 3 1194
野性不改
野性不改 2020-12-09 22:07

I have birth dates on my site in format 12.01.1980.

$person_date (string) = Day.Month.Year

Want to add an oldness of the perso

3条回答
  •  一整个雨季
    2020-12-09 22:45

    You can use the DateTime class and its diff() method.

    diff($bday);
    
    printf('%d years, %d month, %d days', $diff->y, $diff->m, $diff->d);
    

    prints 29 years, 7 month, 20 days

提交回复
热议问题