Increment Timer Javascript
Timer with pure javascript
by Raunak Kathuria
HTML
<div id="countdown2"></div>
JavaScript
var input = {
year: 0,
month: 0,
day: 0,
hours: 2,
minutes: 10,
seconds: 30
};
var timestamp = new Date(input.year, input.month, input.day,
input.hours, input.minutes, input.seconds);
var interval = 1;
setInterval(function () {
timestamp = new Date(timestamp.getTime() + interval * 1000);
document.getElementById('countdown2').innerHTML = timestamp.getDay() + 'd:' + timestamp.getHours() + 'h:' + timestamp.getMinutes() + 'm:' + timestamp.getSeconds() + 's';
}, Math.abs(interval) * 1000);