SOURCE

console 命令行工具 X clear

                    
>
console
 window.onload = function () {
        var aInp = document.getElementsByClassName("aInp");
        var btn = document.getElementsByTagName("button")[0];
        var timer =null;
        var str= '';

        btn.onclick = function () {
            var iNew=new Date(aInp[0].value); //月份 0=>1
            //数字形式 new Date(2018,7,9,13,65,0);
            //字符串形式  new Date('August 9,2018,14:05:05');

            clearInterval(timer);

            timer = setInterval(function () {
                var iNow=new Date();
                var t=Math.floor( (iNew-iNow)/1000 );
                if(t >= 0){
                    str= Math.floor(t/86400)+"天"+Math.floor(t%86400/3600)+"时"+Math.floor(t%86400%3600/60)+"分"+t%60+"秒";
                    aInp[1].value  = str;
                }else{
                    clearInterval(timer);
                }



            },1000);

        };

        //天:Math.floor(t/86400)
        //时:Math.floor(t%86400/3600)
        //分:Math.floor(t%86400%3600/60)
        //秒:t%60


    };
<input type="text" value="August 9,2018,14:45:05"  class="aInp"/>
<input type="text" value="" class="aInp"/>
<button>开始倒计时</button>