可能重复:
How to calculate the difference between two dates using PHP?
有人可以向我显示将生日计算为年月日时分和秒的代码
示例:Aug 8, 1993
预期结果如下:
截至Dec 16, 2012 11:04
您的年龄为19 years 4 months 12 days 11 hours 4 minutes and 23 seconds
答案 0 :(得分:1)
试试这个
<?php
$birthday = new DateTime("2007-03-24");
$today = new DateTime();
$interval = $birthday->diff($today);
echo "difference " . $interval->y . " years, " . $interval->m." months, ".$interval->d." days ";
?>
How to calculate the difference between two dates using PHP?