Show clock/time increment from javascript

I tried to show/increment the only time(Hours, Minutes and Seconds) like a timer from getting server side, but it’s not working for me.

For this I tried below code.

Can you please help me to run the specified time (Server Time) to run as Timer.

What I have tried:


ScriptManager.RegisterStartupScript(Page, this.GetType(), "close", "OnRunnTimer("+0.21023+");", true);

// JS COde

//Server time I am sending serverTimeP = 0.21023

function OnRunnTimer(timeP) { 
            setInterval(function () { runJSTimer(timeP); }, 1000);

 function runJSTimer(serverTimeP) {

var d = new Date();
             var hours = d.getHours();
             var min = d.getMinutes();
             var sec = d.getSeconds();
             lblJsTimer.SetText(hours + ":" + min + ":" + sec);


enter image description here
Can you please help on this.

17 thoughts on “Show clock/time increment from javascript”

Leave a Comment