function Timer() {
this.initialTime = 0;
this.timeStart = null;
this.getTotalTime = function() {
timeEnd = new Date();
diff = timeEnd.getTime() - this.timeStart.getTime();
return diff+this.initialTime;
};
this.formatTime = function() {
interval = new Date(this.getTotalTime());
return interval.getHours() + ":" + interval.getMinutes() + ":" + interval.getSeconds();
};
this.start = function() {
this.timeStart = new Date();
setTimeout("this.updateTime()", 1000);
};
this.updateTime = function() {
alert(this.formatTime());
setTimeout("this.updateTime()", 1000);
};
}
timer = new Timer();
timer.start();
I am getting an error:
this.updateTime is not a function
Any ideas?
Thanks