javascript - Add minutes to while loop -
i trying make users end time add 30 mintues on , on over , display time
function() { var totime = new date(result2); while (true) { var totime30 = new date(totime.gettime() + totime.gettimezoneoffset() *30 * 1000); var totime60 = new date(totime30.gettime() + 30 * 60 * 1000); var addmin = totime30 + "" + totime60; alert(addmin); break; }
right code adds first ex 02:00 02:30 how keeps adding 30 minutes time?
update
var totime = new date(result2); while (true) { var icount = 0; var totime30 = new date(totime.gettime() + totime.gettimezoneoffset() *30 * 1000); var totime60 = new date(totime30.gettime() + 30 * 60 * 1000); var addmin = totime30 + "" + totime60 + (++icount); alert(addmin); break; }
you cannot use variable before initialization. should like
var icount = 0; var t = new date(); var totime30 = new date(t.gettime() + t.gettimezoneoffset() * 30 * 1000); console.log(t.gettime() + " - " + totime30.gettime() + " - " + (icount++)); .> "1417509086906 - 1417505486906 - 0"
Comments
Post a Comment