📜  按生日计算人的年龄php代码示例

📅  最后修改于: 2022-03-11 14:54:51.884000             🧑  作者: Mango

代码示例1
public function getAge($date)
    {
        
        $dob = new DateTime($date);
        
        $now = new DateTime();
         
        $difference = $now->diff($dob);
         
        $age = $difference->y;
         
        return  $age;
    }