JavaScript NTP time?

First of all, the JS scheduler has a certain granularity - that is, you can request an interval smaller than, say, 20 msec, but it will not fire immediately - what you could see is 20 events fired off every 20 msec Second, even if you could, this is not a good idea: you would be making 1000 requests every second from every computer which uses this script. Even if the client and their connections could handle this, it's nothing short of a DDoS for the JSON server What you could do is this: get time from JSON-NTP (once), this will be a Date get local time (once), this will be a Date calculate the difference between NTP and local time (once), this will likely be the number of msec that local time is off for every time calculation, take the difference into account.

First of all, the JS scheduler has a certain granularity - that is, you can request an interval smaller than, say, 20 msec, but it will not fire immediately - what you could see is 20 events fired off every 20 msec. Second, even if you could, this is not a good idea: you would be making 1000 requests every second, from every computer which uses this script. Even if the client and their connections could handle this, it's nothing short of a DDoS for the JSON server.

What you could do is this: get time from JSON-NTP (once), this will be a Date get local time (once), this will be a Date calculate the difference between NTP and local time (once), this will likely be the number of msec that local time is off for every time calculation, take the difference into account.

Thank you! This is the way :) – David Apr 2 at 9:13.

I'm not sure you understand what NTP is for: Namely sychronization of the internal clock in the computer, not as use for a clock in itself. I would suggest, that you connect to the NTP service once to get the difference to the internal time of the client and use that to correct it for display. But I'm not exactly sure, why a comparison to the client computer time is not sufficient.

Put this right at the top of your document: var clientTime = new Date(); and this right at the bottom of your document: var serverTime = new Date(""); var deltaTime = serverTime - clientTime; // in milliseconds (expected accuracy.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions