php 判断过去离现在几年的函数

function gettime($worktime){
$time=time();
$amount=date("Y",$time)-date("Y",strtotime($worktime));
if (date("m",$time)<date("m",strtotime($worktime))) {
$amount--;
}
elseif (date("m",$time)==date("m",strtotime($worktime))) {
if (date("d",$time)<date("d",strtotime($worktime))) {
$amount--;
}
}
return $amount;
}

posted on 2015-05-22 11:33  liuwenbohhh  阅读(166)  评论(0编辑  收藏  举报