Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello All,

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:

JavaScript
//Server time I am sending serverTimeP = 0.21023

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

 function runJSTimer(serverTimeP) {

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

}
Posted
Updated 17-Feb-21 2:18am
v2
Comments
20212a 17-Feb-21 9:17am    
What is wrong with this code? If you debug it, you'll find out.
Bojjaiah 17-Feb-21 9:36am    
Not incrementing/showing clock correctly.
20212a 17-Feb-21 9:44am    
What is lblJsTimer?
Bojjaiah 17-Feb-21 9:48am    
It's a DevExpress ASPxLabel having property so that we can set the text directly from JavaScript using ClientInstanceName property.
20212a 17-Feb-21 9:56am    
And when you debug your code, what happens? Does that line of code run? I don't see where you declare lblJsTimer.

1 solution

"https://www.w3schools.com/js/tryit.asp?filename=tryjs_timing2" this may help.
CMD in DOS will add date and time to timelog.txt
when executed again it will append current date & time to timelog.txt

echo Today is: %date% %time% >> timelog.txt

Content of timelog.txt
Today is: Sun 02/21/2021 17:46:48.81
Today is: Sun 02/21/2021 17:46:50.13
 
Share this answer
 
v2
Comments
Richard Deeming 22-Feb-21 5:49am    
What does a DOS command appending to a log file have to do with the question?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900