var dateObj = new Date(); var dateObjNew = new Date(); var i = 0; while(i < 1){ //some logic anything.then(function(data){ dateObj.setTime(dateObj.getTime() + 300000); //300000 is in milliseconds //means I would add 300k milliseconds into the Date object }); anything2.then(function(data){ dateObjNew.setTime(dateObjNew.getTime() + 100000); //add 100000 milliseconds here }); alert('Remaining Time: '+ (dateObj - dateObjNew)); //here the alert will show 'Remaining Time: 0' because the 2 date objects value has been defaulted back to new Date() where they do not take the latest modified values. i++; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)