在PHP中转换几秒钟

时间:2013-08-10 12:12:05

标签: php datetime time

我在变量中有259201 seconds

如何在"normally" 4 days 00:00:01时间内对其进行转换?

提前谢谢!

1 个答案:

答案 0 :(得分:2)

在PHP中执行此操作非常简单:

<?php
$secs = "259201";

$days = gmdate("d", $secs);

$hoursminssecs = gmdate("H:i:s", $secs);

if ($days == 0) { $days = empty($days); } elseif ($days == "1") { $days = "1 day"; } else { $days = $days." days"; }

echo $days." - ".$hoursminssecs
?>

希望它可以帮到你!