[Javascript] Countdown clock with Javascript and PHP

代码
<?php
$time
= date("M d, Y", strtotime('2010-09-28'));
?>
<script type="text/javascript">
//<![CDATA[
function getRTime()
{
var EndTime = Date.parse('<?php echo $time;?>');
var NowTime = new Date();
var nMS =EndTime - NowTime.getTime();
var nH=Math.floor(nMS/(1000*60*60));
var nM=Math.floor(nMS/(1000*60)) % 60;
var nS=Math.floor(nMS/1000) % 60;
document.getElementById("remainH").html(nH);
document.getElementById(
"remainM").html(nM);
document.getElementById(
"remainS").html(nS);
setTimeout(
"getRTime()",1000);
}
getRTime();
//]]>
</script>

 

代码
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr class="title">
<td width="20%" rowspan="2" class="nfont">time left</td>
<td width="28%">hours</td>
<td width="26%">mins</td>
<td width="26%">secs</td>
</tr>
<tr class="number">
<td id="remainH">0</td>
<td id="remainM">0</td>
<td id="remainS">0</td>
</tr>
</table>

 

posted @ 2010-09-28 15:04  DavidHHuan  阅读(375)  评论(0编辑  收藏  举报