<?php
//php的時間是以秒算。js的時間以毫秒算
//配置每天的活動時間段
$endtime =$endtime;//從後天將時間傳到前臺
$nowtime = time();//獲取當前時間
/*if ($nowtime<$starttime){
die("活動還沒開始,活動時間是:{$starttimestr}至{$endtimestr}");
}*/
$lefttime = $endtime-$nowtime; //實際剩下的時間(秒)
?>
<SCRIPT LANGUAGE="JavaScript">
<!-- //
var runtimes = 0;
function GetRTime(){
var nMS = <?php echo $lefttime;?>*1000-runtimes*1000;
var nD=Math.floor(nMS/(24 * 60 * 60 * 1000));//還有多少天
var nH=Math.floor(nMS/(1000*60*60))%24; //還有多少小時
var nM=Math.floor(nMS/(1000*60)) % 60; //還有多少分鐘
var nS=Math.floor(nMS/1000) % 60; //還有多少秒
var hour=nD*24+nH;
$(".hour1").html(hour);
$(".minute1").html(nM);
$(".second1").html(nS);
if(nMS>5*59*1000&&nMS<=5*60*1000) // 5分鐘是 5*60*1000毫秒;4分鐘是4*60*1000
{
alert("還有最後五分鐘!");
}
runtimes++;
setTimeout("GetRTime()",1000);
}
window.οnlοad=GetRTime;
// -->
</script>
<body>
<div id="container">
<div id="header"> <img src="image/romwezt_03.jpg" /> </div>
<div id="timer" class="yangshi">
<span class="hour1"></span> <span class="minute1"></span> <span class="second1"></span>
</div></body>