Luiz E. Luiz E. - 1 month ago 6
Javascript Question

How to count up time in javascript (maybe with jquery)

On my app, I have a command:

@uptime = 'uprecords -s | awk '{ print $5 }'

that returns the current uptime from computer (using uptimed).

it returns something like 01:00:00 (hours, minutes, seconds) and I want to count up this time.

How do I do that? I tried some count up jquery plugins but none of them worked like I want
How do you guys count up?

Thanks in advance


I think I wasn't clear enough

What I want is to catch this uptime from my server (already done it), and via javascript, make it dinamically, counting up this current uptime, so if the user got away from keyboard, by example, the uptime still increases


You can use setInterval:

var seconds = 2642; // uptime in seconds
var timer = setInterval(
    function() {
    }, 1000

Also, see this reference on JS time functions.