首页 LMVE论坛 资讯 插画 时光机 我的社区 用户 搜索

[js]js倒计时

无闻风
发表于 2019-10-14 01:06:23
0
39

结果输出到<div id="djs"></div>

<div id="djs"></div>
<script type="text/javascript">
window.onload=clock;
function clock()
{
    var today=new Date(),h=today.getHours(),m=today.getMinutes(),s=today.getSeconds();
    var stopTime=new Date("9 22 2021 00:00:00"),stopH=stopTime.getHours(),stopM=stopTime.getMinutes(),stopS=stopTime.getSeconds();
    var shenyu=stopTime.getTime()-today.getTime(),shengyuD=parseInt(shenyu/(60*60*24*1000)),D=parseInt(shenyu)-parseInt(shengyuD*60*60*24*1000),shengyuH=parseInt(D/(60*60*1000)),H=D-shengyuH*60*60*1000,shengyuM=parseInt(H/(60*1000)),M=H-shengyuM*60*1000;
    S=parseInt((shenyu-shengyuD*60*60*24*1000-shengyuH*60*60*1000-shengyuM*60*1000)/1000);
    if(shengyuH<10)
    {
        shengyuH='0'+shengyuH;
    }
    if(shengyuM<10)
    {
        shengyuM='0'+shengyuM;
    }
    if(S<10)
    {
        S='0'+S;
    }
    document.getElementById("djs").innerHTML=(shengyuD+" Days "+shengyuH+":"+shengyuM+":"+S);
    setTimeout(clock,1000);
}
</script>


最后修改 2019-10-14 01:06:23
0
39
用户评论
一起折腾