距离2020年一月30号还剩。。。

<!DOCTYPE html>
<html>

<head>
    <title></title>
    <meta charset="utf-8">
    <style>
    #con {
        width: 500px;
        height: 200px;
        border: 2px solid fuchsia;
        margin: 30px auto;
    }
    
    #con1 {
        width: 500px;
        height: 100px;
        line-height: 100px;
        font-size: 20px;
    }
    
    #con2 {
        width: 500px;
        height: 100px;
        line-height: 100px;
        font-size: 30px;
        color: darkturquoise
    }
    </style>
</head>

<body>
    <div id="con">
        <div id="con1">距离过年还剩:</div>
        <div id="con2"></div>
    </div>
    <script>
    var con, con1, con2;
    con = document.getElementById("con")
    con1 = document.getElementById("con1")
    con2 = document.getElementById("con2")

    function auto() {
        var time
        time = new Date()
        newtime = new Date(2020, 0, 30)
        tt = newtime.getTime() - time.getTime()
        console.log(tt)
        day = Math.floor(tt / 1000 / 60 / 60 / 24)
        hours = Math.floor((tt - day * 24 * 60 * 60 * 1000) / 1000 / 60 / 60)
        minutes = Math.floor((tt - day * 24 * 60 * 60 * 1000 - hours * 60 * 60 * 1000) / 1000 / 60)
        seconds = Math.floor((tt - day * 24 * 60 * 60 * 1000 - hours * 60 * 60 * 1000 - minutes * 60 * 1000) / 1000)
        millioseconds = Math.floor((tt - day * 24 * 60 * 60 * 1000 - hours * 60 * 60 * 1000 - minutes * 60 * 1000 - seconds * 1000))
            //console.log(day+"天"+hours+"小时"+minutes+"分"+seconds+"秒")
        con2.innerHTML = day + "天" + hours + "小时" + minutes + "分" + seconds + "秒" + millioseconds + "毫秒"
            // console.log(  time.getTime()/1000/60/60/24/365)
    }

    setInterval(auto, 1)
    </script>
</body>

</html>

  

转载于:https://www.cnblogs.com/wysdddh/p/6260365.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值