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);
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);
};
};
<input type="text" value="August 9,2018,14:45:05" class="aInp"/>
<input type="text" value="" class="aInp"/>
<button>开始倒计时</button>