码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2017-01-07 22:29:57      阅读:302      评论:0      收藏:0      [点我收藏+]

标签:char   function   ios   new   cti   htm   document   margin   element   

<!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>

  

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

标签:char   function   ios   new   cti   htm   document   margin   element   

原文地址:http://www.cnblogs.com/wysdddh/p/6260365.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!