Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] [OT] Displaying time and starting from zero
- Date: Thu, 25 Mar 2010 10:00:08 +0900
- From: Dave M G <dave@example.com>
- Subject: Re: [tlug] [OT] Displaying time and starting from zero
- References: <4BA9D37D.6030402@example.com> <4fac0ea81003240326h555714a7i5b3df39e23ecaef6@example.com>
- User-agent: Thunderbird 2.0.0.24 (X11/20100317)
Travis, Godwin, Thank you for replying. Here's the code. First, this is a function that adds time to my timer. My timer works by marking a specific time in the future as a Unix time stamp. this.addTime = function(hours,minutes) { // convert to milliseconds var addHours = hours*3600000; var addMinutes = minutes*60000; timeRemain.timeStamp = timeRemain.timeStamp + addHours + addMinutes; } And here's the function that displays the remaining time on the timer (thanks to Darren for this). The time remaining is a result of the time marked in the future minus the current time: 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); minutes = minutes - (hours*60); remainTime = hours + ":" + (minutes < 10 ? ("0"+minutes):minutes); return remainTime; The user has a button that will add one hour to the timer. If I call the addTime function like this: timeRemain.addTime(1,0); ... The display shows 0:59 remaining. If I call the addTime function like this: timeRemain.addTime(1,.1); ... the display shows 1:00 remaining. (.1 minutes was the lowest I could go before it would change to 0:59) -- Dave M G
- Follow-Ups:
- Re: [tlug] [OT] Displaying time and starting from zero
- From: Darren Cook
- References:
- [tlug] [OT] Displaying time and starting from zero
- From: Dave M G
- Re: [tlug] [OT] Displaying time and starting from zero
- From: Travis Cardwell
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] [OT] Displaying time and starting from zero
- Next by Date: Re: [tlug] [OT] Displaying time and starting from zero
- Previous by thread: Re: [tlug] [OT] Displaying time and starting from zero
- Next by thread: Re: [tlug] [OT] Displaying time and starting from zero
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links