<?php

namespace App\Lib;

use DateTime;

class Tools
{
    //根据生日 获取年龄
    public static function GetAge($birthday) {
        $dob = new DateTime($birthday);
        $now = new DateTime();

        // 计算两个日期之间的差值
        $interval = $now->diff($dob);

        // 返回年龄
        return $interval->y;
    }
}
