时间转换到几天前,刚刚方法

/作用:总结五个时间戳之间距离的日时转眼
//$begin_time 初叶时间戳
//$end_time 甘休时间戳
function timediff($begin_time,$end_time)
{
  if($begin_time < $end_time){
    $starttime = $begin_time;
    $endtime = $end_time;
  }else{
    $starttime = $end_time;
    $endtime = $begin_time;
  }

//计算小时数

  //计算天数
  $timediff = $endtime-$starttime;
  $days = intval($timediff/86400);
  //总结时辰数
  $remain = $timediff%86400;
  $hours = intval($remain/3600);
  //总括分钟数
  $remain = $remain%3600;
  $mins = intval($remain/60);
  //总计秒数
  $secs = $remain%60;
  $res = array(“day” => $days,”hour” => $hours,”min” =>
$mins,”sec” => $secs);
  return $res;
}

return$res[‘min’] .’分钟前’;

return$res[‘day’] .’天前’;

$starttime=$end_time;

if($res[‘sec’] >0) {

public static function timediff($begin_time,$end_time)

$endtime=$begin_time;

}

$remain=$timediff%86400;

$starttime=$begin_time;

{

}

}

$days=intval($timediff/86400);

}

$hours=intval($remain/3600);

if($res[‘min’] >0) {

相关文章