Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] [OT] Displaying time and starting from zero



> currTime = new Date();
> var elapsed = timeRemain.timeStamp - currTime.getTime();
> var seconds = Math.floor(elapsed/1000);
> var minutes = Math.floor(seconds/60);
> var hours = Math.floor(minutes/60);

Math.floor() means divide and round down. I think you'll get what you
want by changing the first one to round-up:
  var seconds = Math.ceil(elapsed/1000);

I.e. 1ms has passed, so if the seconds rounds down it appears as if 1
whole seconds has passed.

(But keep minutes and hours rounding down!)

Darren


-- 
Darren Cook, Software Researcher/Developer

http://dcook.org/gobet/  (Shodan Go Bet - who will win?)
http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links