Is there some window variable in javascript that I can use or a way to use a timer to track elapsed time without using a date object? flash.utils.getTimer works great in the flash version of this application and I'm trying to port it to javascript. I can't risk changes to the system clock causing security problems, so I don't want to use the Date object.
I have a servertimestamp and I would like to create a timer that is independent of the operating system time to calculate the current server time. I'll use this calculated value to allow different operations during windows on the server time. I'm not concerned about javascript hacking as I know there's no security there, but I would like to prevent the casual user from messing around with the availability of certain features.
Thanks
Added for clarification:
This project relates to live video events. The live video has a start time relative to the server and through another webservice I am able to grab the server time. What I need to do is to maintain this server time on the client machine independently of the user's local time to determine when the live stream should start and stop on the client. So the problem isn't really the format that I store the server time, it's how do I get the elapsed time from when I grabbed the server time without using a date object.
You could have the server send the server time and store it in a javascript Date variable. Then you can base your calculations on this variable knowing that it will be the server time and won't be dependent on the client system clock. As far as executing some javascript method at regular intervals is concerned you could use the setTimeout and setInterval methods.
You could create your own timer object:
and use it:
Use the
init
parameter to start the timer with any given date value you prefer.