Skip to content

Instantly share code, notes, and snippets.

@ManuelColombo
Created October 4, 2013 11:34
Show Gist options
  • Save ManuelColombo/6824590 to your computer and use it in GitHub Desktop.
Save ManuelColombo/6824590 to your computer and use it in GitHub Desktop.
Simple timer
var data = new Date();
var date = [
new Date(2012, 8, 14),
new Date(2012, 8, 19),
new Date(2012, 8, 25)
//var endData = new Date(year, month, day, hours, minutes, seconds, milliseconds);
];
$(function start(){
for(i=0; i<3; i++){
date[i].setTime( date[i].getTime() - data.getTime() );
}
timer(date);
});
function timer(){
for(i=0; i<3; i++){
if(data.getTime()>0){
Gg = data.getDate();
if(Gg==1) Gg+=' gg'; else Gg+=' gg';
Hh = data.getHours();
if(Hh<10) Hh = "0" + Hh;
Mm = data.getMinutes();
if(Mm<10) Mm="0"+ Mm;
/*Ss = data.getSeconds();
if(Ss<10) Ss = "0"+ Ss;*/
$('.calendari a span.timer'+i).html(Gg + ' ' + Hh + ':' + Mm + '&rsquo;');//:' + Ss + '&rdquo;');
}
}
window.setTimeout("timer();", 60000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment