【发布时间】:2011-11-10 17:49:49
【问题描述】:
我想知道这些人的年龄。
$time=$row['date_of_birth'];
$date=explode("-", $time);//gets the date birth from the database and puts it into an array
$a=getdate();//gets todays date
$diff_date= gregoriantojd($a["mon"],a["mday"],a["year"] ) - gregoriantojd(date[1],date[2],date[0]);//subtracts the differences between the dates, this is returned in seconds..
问题是这是否是这样做的方法?以及如何转换秒并将它们转换为年(作为整数)?!
编辑: 我认为最后一行应该是这样的:
return floor($diff_date /60*60*24*365);
【问题讨论】:
-
返回层($diff_date /60*60*24*365);最后一行应该是那个吗?