I need to get a uniform javascript time for all clients in our private server. So I want to set the javascript time of a client on initialization to the time of the server.
Right now I am thinking of setting a setInterval that will increment a variable that has a timestamp, but I think it would be too much to have a setInterval running in the back every n milisecond.
So is there a way for me to set the starting time of javascript? so every instance of new Date will be based on that, not the system time of the client?
A difference of 1-2 seconds from the server time is ok but if a difference of milliseconds is achievable then that would be better.
Any suggestions?
new Date().getTime()would get the timestamp of the client system, I want thenew Date()to be based on the initialized timestamp that I provide.