我试图让时间对抗它工作正常,但它不会在00:00:00停止并返回到24:00:00。 这是我的代码。
<?php
session_start();
$from_time1 = date('Y-m-d H:i:s');
$to_time1 = $_SESSION['end_time'];
$timefirst = strtotime($from_time1);
$timesecond = strtotime($to_time1);
$difference = $timesecond-$timefirst;
echo gmdate("H:i:s",$difference);
?>
答案 0 :(得分:0)
<?php
session_start();
$from_time1 = date('Y-m-d H:i:s');
$to_time1 = $_SESSION['end_time'];
$timefirst = strtotime($from_time1);
$timesecond = strtotime($to_time1);
$difference = $timesecond-$timefirst;
$diff= gmdate("H:i:s",$difference);
if($diff == '00:00:00'){
//stop the timer logic
}else{
echo $diff;
}
?>
你可以试试这个