News新闻

业界新闻动态、技术前沿
Who are we?

您的位置:首页      网络营销      php 判断过去离现在几年的函数(实例代码)

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

如下所示:

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;
}

    我要评论
    共有 人参与,评论 条,顶帖 [点击查看]
  • 验证码:
  • 所有评论仅代表网友意见,与本站立场无关!