I am going to make use of same function I created in this post:
Let’s modify the code in the post above slightly to get what we want.
HTML
We’re going to show hours, minutes and seconds elapsed. You can add microseconds as well, just like the stopwatch example or just keep minutes and seconds.
CSS
Let’s give it a nice look using CSS. It’s not required for background processing for e.g. if you want to keep track of user’s timing activities.
JavaScript
Finally, let’s add the modified JavaScript function.
Here’s the demo and JavaScript code.
elapsed time setTimeout stopwatch