如何从php中查找出生日期


How to find out birth day from php

如何从php程序中找到以年和月为单位的当前年龄。我能查到今天的日期和时间。但我需要使用php公式来找出任何未知人员的年龄。感谢

例如:(我没有测试过代码,但它应该可以工作)

<?php
     //full age calulator
     $bday = new DateTime('02.08.1991');//dd.mm.yyyy
     $today = new DateTime('00:00:00'); // Current date
     $diff = $today->diff($bday);
     printf('%d years, %d month, %d days', $diff->y, $diff->m, $diff->d);
    ?>