Created
July 15, 2013 17:05
-
-
Save steppefox/6001603 to your computer and use it in GitHub Desktop.
Simple countdown on javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
timeend= new Date(); | |
timeend= new Date(2013,0,1); | |
// для задания обратного отсчета до определенной даты укажите дату в формате:2013,0,1 | |
// timeend= new Date(ГОД, МЕСЯЦ-1, ДЕНЬ); | |
// Для задания даты с точностью до времени укажите дату в формате: | |
// timeend= new Date(ГОД, МЕСЯЦ-1, ДЕНЬ, ЧАСЫ-1, МИНУТЫ); | |
function time() { | |
today = new Date(); | |
today = Math.floor((timeend-today)/1000); | |
tsec=today%60; today=Math.floor(today/60); if(tsec<10)tsec='0'+tsec; | |
tmin=today%60; today=Math.floor(today/60); if(tmin<10)tmin='0'+tmin; | |
thour=today%24; today=Math.floor(today/24); | |
timestr="<table id='otschet'><tr><td align='center'><b>"+today +"</b><br> <span style='font-size:12px;'>дней</span> </td><td align='center'><b>"+ thour+"</b><br> <span style='font-size:12px;'>часов</span> </td><td align='center'><b>"+tmin+"</b><br> <span style='font-size:12px;'>минут</span> </td><td align='center'><b>"+tsec+"</b><br> <span style='font-size:12px;'>секунд</span></td></tr></table>"; | |
document.getElementById('t').innerHTML=timestr; | |
window.setTimeout("time()",1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment