下载地址:http://download.csdn.net/detail/dawenxiz/4334751
<script type="text/javascript">
$(function(){
function ShowTimes(){
//month dd,yyyy hh:mm:ss
var AfterTime= 1338278104000;
var LeaveTime = AfterTime - new Date();
$("#hour").html("00");
$("#minute").html("00");
$("#second").html("00");
$("#min_second").html("0");
if (LeaveTime > 0) {
var LeaveDays=Math.floor(LeaveTime/(1000*60*60*24));//天
var LeaveHours=Math.floor(LeaveTime/(1000*60*60)%24);//时
var LeaveMinutes=Math.floor(LeaveTime/(1000*60)%60);//分
var LeaveSeconds=Math.floor(LeaveTime/1000%60);//秒
var c=new Date();
var q=c.getMilliseconds();
if(q<10)//因为毫秒为一位数时只占一个字符位置,会让毫秒二字变动位置
{
q="00"+c.getMilliseconds();
}
if(q>=10 && q<100)//因为毫秒为两位数时只占两个字符位置,会让毫秒二字变动位置
{
q="0"+c.getMilliseconds();
}
var qs = 9 - parseInt(q/100);
if (LeaveHours < 10) {
LeaveHours = "0" + LeaveHours;
}
if (LeaveMinutes < 10) {
LeaveMinutes = "0" + LeaveMinutes;
}
$("#hour").html(LeaveHours);
$("#minute").html(LeaveMinutes);
$("#second").html(LeaveSeconds);
$("#min_second").html(qs);
}
}
setInterval(ShowTimes,10);
});
</script>