Js countdown distal (to the millisecond)

Man of few words said, directly on the code:

  There needs to take immediate,

<html>

<head>
    <style>
        div{
            width:100%;
             text-align:center;
            font-size: 14px;
        }
    </style>
</head>
        <div id="go">
        </div>
<body>
    <script>
        function countTime(time,id) {
                =datewas new new a Date ();
                 var now = date.getTime ();               
                 var endDate =  new new a Date (Time); // set deadline 
                var End = endDate.getTime ();
                 var leftTime = End - now; // time difference                               
                var D, H, m, S, MS;
                 IF (leftTime > =  0 ) { 
                    D = Math.floor (leftTime /  1000  /  60  / 60 / 24);
                    h = Math.floor(leftTime / 1000 / 60 / 60 % 24);
                    m = Math.floor(leftTime / 1000 / 60 % 60);
                    s = Math.floor(leftTime / 1000 % 60);
                    ms = Math.floor(leftTime % 1000);
                    if(ms < 100) {
                        ms = "0" + ms;
                    }
                    if(s < 10) {
                        s = "0" + s;
                    }
                    if(m < 10) {
                        m = "0" + m;
                    }
                    if(h < 10) {
                        h = "0" + h;
                    } 
                    // countdown assigned to the div 
                document.getElementById (ID) .innerHTML = D +  " days "  + H +  " when "  + m +  " min "  + S +  " s " +   MS +  " millisecond " ; 
                } the else { 
                    the console.log ( ' Closed ' )
                     // countdown assigned to the div
                     document.getElementById (id) .innerHTML=  " Has opened grab " 
                } 
                // recursive call countTime second method, the time display dynamic effects 
               return leftTime 
            } 
            // called by-passed and the end of the countdown time where the content id name 
            var S = the setInterval ( function () {
                    var a dates =   countTime ( " 2019-7-2 10:32:00 " , " Go " );
                     IF (a dates <= 0 ) {  
                        the clearInterval (S)
                    } 
            }, 50 )
     </ Script >
</body>

</html>
        

 

Guess you like

Origin www.cnblogs.com/wgs-blog/p/11119139.html