0
Answer

Auction timer issue after extension in lot

Ask a question
I am working on auction site in asp.net. When we click on increment bid button of each lot , If time in timer is less than 3 minutes then lot time gets extended for 3 minutes but timers of each lot get mismatched by couple of seconds and my client don't want that.
This is calling of JS function to extend timing for lot: 
 
eval('timer' + auctionLotId).cdtime('timer' + auctionLotId + "', '" + auctioncurrtime + "', '" + auctionendtimer + "', " + auctionLotId);
 
This is JS file for updating timer :
 
function cdtime(container, currentTime, targetdate, AuctionLotID) {
if (!document.getElementById || !document.getElementById(container))
return;
this.container = document.getElementById(container);
this.auctionLotID = AuctionLotID;
var now = new Date();
//this.currentTime = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes(), now.getSeconds());
//this.currentTime = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds());
this.currentTime = new Date(currentTime);
this.targetdate = new Date(targetdate);
this.currentTime.setSeconds(this.currentTime.getSeconds() - 1);
//alert('currentTime: ' + this.currentTime);
//this.targetdate = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds());
this.timesup = false;
this.updateTime();
}
cdtime.prototype.resetTimer = function (newdate) {
var thisobj = this;
this.targetdate = new Date(newdate);
this.extended = 1;
this.timesup = false;
//this.updateTime(); //by yogesh
}
cdtime.prototype.updateTime = function () {
//alert(this.currentTime);
var thisobj = this;
this.currentTime.setSeconds(this.currentTime.getSeconds() + 1);
this.tim = setTimeout(function () { thisobj.updateTime() }, 1000); //update time every second
//timer = setTimeout(updatetimer, 1000);
}