倒计时代码

贴两段倒计时代码

<br>倒计时已结束<br>
<span id="span_dt_dt" style='border:1px solid black;background-color:#FFFFFF' ></span>
<SCRIPT language=javascript>
<!--
//document.write("");

function show_student163_time(){
window.setTimeout("show_student163_time()", 1000);
BirthDay=new Date("15-11-2016");//改成你的计时日期
today=new Date();
timeold=(BirthDay.getTime()-today.getTime());
sectimeold=timeold/1000
secondsold=Math.floor(sectimeold);
msPerDay=24*60*60*1000
e_daysold=timeold/msPerDay
daysold=Math.floor(e_daysold);
e_hrsold=(e_daysold-daysold)*24;
hrsold=Math.floor(e_hrsold);
e_minsold=(e_hrsold-hrsold)*60;
minsold=Math.floor((e_hrsold-hrsold)*60);
seconds=Math.floor((e_minsold-minsold)*60);
span_dt_dt.innerHTML=daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒" ;

}
show_student163_time();
//-->
</SCRIPT>
<body>
<div id="timer"></div>
<script type="text/javascript" language="javascript">
var endDate=new Date(2016,11,11,17,05,40);//年月日时分秒,月要减去1
(function daoJiShi()
{
var now=new Date();
var oft=Math.round((endDate-now)/1000);
var ofd=parseInt(oft/3600/24);
var ofh=parseInt((oft%(3600*24))/3600);
var ofm=parseInt((oft%3600)/60);
var ofs=oft%60;
document.getElementById('timer').innerHTML='还有 '+ofd+' 天 ' +ofh+ ' 小时 ' +ofm+ ' 分钟 ' +ofs+ ' 秒';
if(ofs<0){document.getElementById('timer').innerHTML='倒计时结束!';return;};
setTimeout('daoJiShi()',1000);
}());

</script>
</body>资源来自网络


欢迎留言