我的计时器在这个页面上"http://jian.comoj.com/countdown.php" rel=“nofollow”>http://jian.comoj.com/countdown.php 没有倒计时。我在这样做时遵循了视频辅导,但不知何故有些不对劲,我不知道是什么。
<?php
include "connect.php";
$query= "select * from product where product_id= 1 ";
$result= mysql_query($query);
$record= mysql_fetch_object($result);
$time= $record->end_time;
date_default_timezone_set( Asia/Singapore );
$unix_time= strtotime($time);
? & gt;
<script type="text/javascript">
function countdown(){
<?php
$now= time();
$sec= $unix_time-$now;
$min= $sec/60;
$hour= $min/60;
$sec %= 60;
$min %= 60;
? & gt;
var hour= <?php echo floor($hour); ? & gt;;
var min= <?php echo $min; ? & gt;;
var sec= <?php echo $sec; ? & gt;;
document.getElementById("hour").innerHTML = hour;
document.getElementById("min").innerHTML = min;
document.getElementById("sec").innerHTML = sec;
setInterval( countdown() ,1000);
}
</script>
<div id="hour"></div>
<div id="min"></div>
<div id="sec"></div>
<script type="text/javascript">countdown();</script>