/* * @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中文网!
相关推荐:
以上就是php根据日期转换成年龄的实现的详细内容,更多请关注php中文网其它相关文章!
![php中文网最新课程二维码](/static/images/article_wechat2021.jpg?1111)
声明:本文原创发布php中文网,转载请注明出处,感谢您的尊重!如有疑问,请联系admin@php.cn处理
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论