Este es el código:
Código Javascript:
Ver original
function CountDown(){ var date = new Date(2015,02,10); var final = new Date(2015,02,11); var days = 0; var hours = 0; var minutes = 0; var seconds = 0; if(final > date){ var difference = (final.getTime() - date.getTime()) / 1000; days = Math.floor(difference / 86400); difference = difference - (86400 * days); hours = Math.floor(difference / 3600); difference = difference - (3600 * hours); minutes = Math.floor(difference / 60); difference = difference - (60 * minutes); seconds = Math.floor(difference); if(days > 0){ $("#contador, #contador2").html(days + " <sup>d</sup> " + hours + " <sup>h</sup> " + minutes + " <sup>m</sup> " + seconds + " <sup>s</sup>"); }else if(days == 0 && hours > 0){ $("#contador").html(hours + " <sup>h</sup> " + minutes + " <sup>m</sup> " + seconds + " <sup>s</sup>"); }else if(hours == 0 && minutes > 0){ $("#contador").html("<span style='color:orange'>" + minutes + " <sup>m</sup> " + seconds + " <sup>s</sup></span>"); }else if(minutes == 0 && seconds > 0){ $("#contador").html("<span style='color:red'>" + seconds + " <sup>s</sup></span>"); }else if(days == 0 && hours == 0 && minutes == 0 && seconds == 0){ $("#contador").html("<span style='color:red; font-size:16px'>Finalizado</span>"); $("#pjr").css("display", "none"); $("#winner").css("display", "block"); } setTimeout("CountDown()", 1000); }else { alert("Error en la fecha del contador"); } }
No se si el codigo esta correto o tiene algo de errores, me gustaría que me ayudaran en esto.
Un saludo