// set the date we're counting down to var target_date1 = new Date('September, 22, 2024 11:00:00').getTime(); // variables for time units var days, hours, minutes, seconds; // get tag element var countdown1 = document.getElementById('countdown1'); // update the tag with id "countdown" every 1 second setInterval(function () { // find the amount of "seconds" between now and target var current_date = new Date().getTime(); var seconds_left1 = (target_date1 - current_date) / 1000; // do some time calculations days1 = parseInt(seconds_left1 / 86400); seconds_left1 = seconds_left1 % 86400; hours1 = parseInt(seconds_left1 / 3600); seconds_left1 = seconds_left1 % 3600; minutes1 = parseInt(seconds_left1 / 60); seconds1 = parseInt(seconds_left1 % 60); // format countdown string + set tag value if(seconds1<0){ countdown1.innerHTML = 'Evento Iniziato'; } else{ countdown1.innerHTML = '' + days1 + ' ' + hours1 + ' ' + minutes1 + ' ' + seconds1 + ' '; } }, 1000);