PHP根据生日计算年龄(周岁)
2015-06-16 14:00
666 查看
4000<?php /** * 根据时间戳计算年龄 * @param $birth * @return mixed */ function howOld($birth) { list($birthYear, $birthMonth, $birthDay) = explode('-', date('Y-m-d', $birth)); list($currentYear, $currentMonth, $currentDay) = explode('-', date('Y-m-d')); $age = $currentYear - $birthYear - 1; if($currentMonth > $birthMonth || $currentMonth == $birthMonth && $currentDay >= $birthDay) $age++; return $age; } ?>
>
相关文章推荐
- vsftpd配置用户是否限制在主目录
- PHP 批量上传文件 大全
- php注意点
- PHPMailer不能连接SMTP服务器的两种常见原因(Could not connect to SMTP host)
- PHP无限级分类的实现(不使用递归)
- TP里的关联查询
- 添加鼠标右键菜单项(EditPlus为例)
- phonegap(cordova)文件上传(Java,PHP)
- 设置FTP账号
- vsftpd详细配置说明
- php面向对象基础概念(构造方法和析构方法)
- phpcms标签使用 —— 系统常量
- RedHat上使用matplotlib进行科学画图
- php采集中国代理服务器网的方法
- php对gzip文件或者字符串解压实例参考
- 在WAMP中添加其它PHP版本
- 74HC166与TPIC6A595分析(转)
- 分享php分页的功能模块
- split和explode的区别
- PHP生成plist数据的方法