Created
August 25, 2010 04:16
-
-
Save StuMx/548841 to your computer and use it in GitHub Desktop.
Un contador de tiempo para un evento en javascript
This file contains 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
<script type="text/javascript"> | |
var millisecs_per_day=86400000 | |
var evnt_name=""//Used during the event | |
var evnt_name_before=""//Used before the event | |
var evnt_name_after=""//Used after the event | |
var evnt_duration=7 //Event duration in days | |
var countdown_time=Date.UTC(2011,6,18, -5);//Year, mont, day. Dont know why the mont is minus 1. | |
var now=new Date(); | |
var now_millisecs=now.valueOf(); | |
var day_cnt= Math.ceil(( countdown_time - now_millisecs)/86400000 ); | |
if ( day_cnt > 1 ) | |
{ | |
document.write("<div align='center'><strong>Faltan </strong><p><font size='+5'>" + day_cnt +"</font></p> días para <br />"+evnt_name_before+"</div>" ); | |
} | |
else if ( day_cnt == 1 ) | |
{ | |
document.write("<div align='center'><strong>Faltan </strong><p><font size='+5'>" + day_cnt +"</font></p> días para <br />"+evnt_name_before+"</div>" ); | |
} | |
else if ( day_cnt == 0 ) | |
{ | |
document.write("<p><div align='center'><font size='+2'>Hoy inicia</font><br />"+evnt_name+"</div></p>"); | |
} | |
else if ( day_cnt > evnt_duration*-1 ) | |
{ | |
day_cnt-=1; | |
document.write("<p><div align='center'><font size='+2'>Día "+ day_cnt*-1 +" de</font><br />"+evnt_name+"</div></p>"); | |
} | |
else if ( day_cnt == (evnt_duration*-1)-1 ) | |
{ | |
day_cnt-=1; | |
document.write("<p><div align='center'>"+evnt_name_after+"<br /> acabó ayer</div></p>"); | |
} | |
else | |
{ | |
day_cnt+=7; | |
document.write( "<p><div align='center'>"+evnt_name_after+"<br /> acabó hace "+ day_cnt*-1 +" días</div></p>"); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment