How to implement countdown?

When we were young, we all hoped that time could be reversed, so how to realize the countdown? The blogger below I typed some codes, and the babies who want to realize the countdown can try to type!
<html >
<head>
<title>倒计时</title>
<script type="text/javascript">
function showtime(){
     var hdate=new Date('2018-11-27 00:00:00');

     var curdate=new Date;


     var htime=Date.parse(hdate)/1000;
     var ctime=Date.parse(curdate)/1000;

     var difftime=htime-ctime;
     var mydiv=document.getElementById('result');

     var day=difftime/(3600*24);
     var intday=parseInt(day);

     var hour=(day-intday)*24;
     var inthour=parseInt(hour);

     var minute=(hour-inthour)*60;
     var intm=parseInt(minute);

     var second=(minute-intm)*60;
     var ints=Math.round(second);

     var timestr=difftime;
     mydiv.innerHTML=intday+'天'+inthour+'小时'+intm+'分钟'+ints+'秒';
     t=setTimeout('showtime()',1000);
    }
    window.onload=showtime;
</script>
</head>
<body>
<div id="result">
</div
></body>
</html>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325638011&siteId=291194637