I have a requirement about implementing a counter of minutes starting from a specific date and I would appreciate if you could kindly give me a hand.
You can save the above code in an html file and view the result.
I would like to ask you, kindly have a look at my code and tell me whether I'm on the right track. However, it seems to me that there is some bug in the code which unfortunately I couldn't manage to detect. For example if at the moment when you open the page, the value of the seconds (read from the current date) is 48 seconds (just an example), then after 59 (when it becomes 00) it does not increment the minutes variable in the code for the first time, but then for next iterations (I mean each updateCounter( ) function call every second), apparently it works as expected.
Thanks a lot for your attention and your guidance,
posted 5 years ago
Ok, I think I found the problem. Instead of using Math.round I had to use Math.floor in the getEllapsedMinutes function and now it works.