I needed a 5 minute countdown for a project I was working on so I hacked this up, It does nothing more and nothing less. Figured I would post it while I was here to save someone else the trouble. (Not that it's in anyway difficult to do.)
Looks like this is perfect for my needs. Anyone knows how to implement this in a webform application
You'd think 1000 would accurately represent 1 second. I found that if I compared ticks to the starting tick value that my elapsed time timer would occationally jump 2 seconds using 1000. By the time 5 minutes elapsed, you'd probably be off by about 5 seconds using this minute second process. On a timer that is dependent on human reactions, this code is fine, it'll be at most 5 seconds slow and if you use the minute/second method used here to display your time, you'd never have a clue your time is at all off.
(Since I didn't use UTCNow, my timer could jump an hour ahead or backwards. Wasn't thinking of anyone playing with code at 2AM on two special days a year when I wrote it and didn't set up the timer to display hours so you'd see 60+ minutes going forward.)
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.