首页  >  问答  >  正文

获取两个时间之间的间隔

//计算两个时间段时长public function GetTimeLong($time1,$time2,$format="i"){    $length = abs($time2 - $time1);    if($format=="d"){        $long = $this->GetFormatOne($length/86400)."天";    }elseif ($format=="h"){        $long = $this->GetFormatOne($length/3600)."小时";    }elseif ($format=="i"){        $long = $this->GetFormatOne($length/60)."分钟";    }else{        $long = $length."秒";    }    return $long;}//保留小数点后一位function GetFormatOne($num){    $result = $format_num = sprintf("%.1f",$num);    return $result;}

XuPing.YangXuPing.Yang1263 天前981

全部回复(0)我来回复

暂无回复
  • 取消回复