I'm trying to do a very basic date-difference calculation with javascript, but am getting mixed behavior from setInterval().
This updates constantly:
var init = setInterval(function(){
document.getElementById("txt").innerHTML = new Date();
}, 1000);
But this only updates once:
var init = setInterval(function(){
var today = new Date();
var started = new Date(); started.setYear(1983);
var difference = today - started;
document.getElementById("txt").innerHTML = difference;
}, 1000);
I don't get it. If I can show the date every second, why can't I show the difference in dates every second?