//计算两个时间段时长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;}