如何在php和javascript中停止00的时间计数器

时间:2017-08-22 18:55:57

标签: javascript php time

我试图让时间对抗它工作正常,但它不会在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);
?>

1 个答案:

答案 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;
   }

?>

你可以试试这个