将秒数转换成时分秒,PHP提供了一个函数gmstrftime,不过该函数仅限于24小时内的秒数转换。对于超过24小时的秒数,我们应该怎么让其显示出来呢,例如 34:02:02
$seconds = 3600*34+122;
function changeTimeType($seconds){
if ($seconds>3600){
$hours = intval($seconds/3600);
$time = $hours.":".gmstrftime('%M:%S', $seconds);
}else{
$time = gmstrftime('%H:%M:%S', $seconds);
}
return $time;
}
echo changeTimeType($seconds);

相关文章:

  • 2021-11-26
  • 2021-12-14
  • 2022-02-22
  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
  • 2021-09-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-08
  • 2022-12-23
  • 2022-12-23
  • 2021-09-19
  • 2021-10-02
相关资源
相似解决方案