php根据日期转换成年龄的实现

首页 编程分享 PHP丨JAVA丨OTHER 正文

昧光 转载 编程分享 2016-07-24 01:43:55

简介 主要介绍了关于php根居日期转换成年龄的实现 ,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下


这篇文章主要介绍了关于php根居日期转换成年龄的实现 ,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下
    /*
     * @param cheack age
     */
    function howOld($birth) {
        $birthday = strtotime($birth);//int strtotime ( string $time [, int $now ] )
        $year = date('Y', $birthday);
        if(($month = (date('m') - date('m', $birthday))) < 0){
            $year++;
        }else if ($month == 0 && date('d') - date('d', $birthday) < 0){
            $year++;
        }
        return date('Y') - $year;

    }
 $data["birthday"] = $this->howOld($birthday);
        var_dump($data["birthday"]);

  

以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网!

相关推荐:


转载链接:http://www.php.cn//php-weizijiaocheng-406054.html


Tags:


本篇评论 —— 揽流光,涤眉霜,清露烈酒一口话苍茫。


    声明:参照站内规则,不文明言论将会删除,谢谢合作。


      最新评论




ABOUT ME

Blogger:袅袅牧童 | Arkin

Ido:PHP攻城狮

WeChat:nnmutong

Email:nnmutong@icloud.com

标签云