当我的计时器转到00:00:00时,下一秒将像23:59:59一样继续倒计时。如何在00:00:00停止计时器,或者当计时器= 00:00:00自动点击按钮时停止
按钮
<input type=submit name=submit value='Get Result' id='submitpaper'>
展示
<div id=response class=timer style=font-size:30px></div>
这是First.php
$duration=$row["duration"];
$_SESSION["duration"]=$duration;
$_SESSION["start_time"]=date("Y-m-d H:i:s");
$end_time=$end_time=date('Y-m-d H:i:s', strtotime('+'.$_SESSION["duration"].'minutes',strtotime($_SESSION["start_time"])));
$_SESSION["end_time"]=$end_time;
?>
这是我的response.php
<?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);
$differenceinseconds=$timesecond-$timefirst;
echo gmdate("H:i:s",$differenceinseconds);
?>
JavaScript位于时间显示页面的位置。
var x = setInterval(test,1000);
function test()
{
var xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","response.php",false);
xmlhttp.send(null);
document.getElementById("response").innerHTML=xmlhttp.responseText;
}
一只萌萌小番薯
相关分类