]
<script>
function Clock()
{
var Today=new Date();
var PPQday=new Date(2010,9-1,28);
var DayTime = (PPQday.getTime()-Today.getTime())/ 1000 / 60 / 60 /24;
var days = parseInt(DayTime);//天
var HourTime =(DayTime - days)*24;
var hours =parseInt(HourTime);//时
var MinutesTime =(HourTime-hours)*60;
var minutes = parseInt(MinutesTime);//分
var SecondTime =(MinutesTime-minutes)*60;
var seconds = parseInt(SecondTime); //秒
var MillisecondTime = (SecondTime-seconds)*100;//取2位
var milliseconds = parseInt(MillisecondTime);//毫秒
document.getElementById("PPQTime").innerHTML= "距宝宝出生还有 "+ days + "天"+ ForMat(hours)+"小时"+ForMat(minutes)+"分"+ForMat(seconds)+"秒"+ForMat(milliseconds)+"毫秒";
setTimeout(Clock,100);
}
function ForMat(data)
{
if(data<10)
return "0"+data;
else
return data;
}
</script>上面的代码主要用到了javascript日期处理技巧与setTimeout实现日期的刷新。