PHP求周岁

WBOY
Release: 2016-06-20 12:43:22
Original
972 people have browsed it

function getAge($birthday) {
    $age = 0;
    $year = $month = $day = 0;
    if (is_array($birthday)) {
        extract($birthday);
    } else {
        if (strpos($birthday, '-') !== false) {
            list($year, $month, $day) = explode('-', $birthday);
            $day = substr($day, 0, 2);
        }
    }
    $age = date('Y') - $year;
    if (date('m')     return $age;
}


    /**
     * 计算年龄
     * @param $args
     * @return number:返回当前年龄
     */
    private function getAge($birthyear,$birthday){
        $year = date("Y");
        $date = date('md');
        $add_age = $birthday         $age = $year - $birthyear + $add_age;
        if($age             $age = 18;
        }
        return $age;
    }

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template