<input type="number" id="day">Дней<br>
<input type="number" id="hour">Часов<br>
<input type="number" id="min">Минут<br>
<button id="st">start</button>
<div id="time"></div>
<script>
var end;
function timer(){
var now = new Date(),
ost = new Date(end - now),
s = Math.floor(ost/1000),
m = Math.floor(s/60),
h = Math.floor(m/60),
d = Math.floor(h/24);
s = s%60+'';
m = m%60+'';
h = h%24+'';
d = d+'';
if(ost>0){
setTimeout(timer, 1000);
time.textContent = `${d}-дней ${h}-часов ${m}-минут ${s}-секунд`;
}
else window.open("http://google.com");
}
st.onclick = e =>{
end = Date.now() + ( day.value*86400000 ) + ( hour.value*3600000) + ( min.value* 60000);
timer();
};
</script>
|