This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Original from http://stackoverflow.com/questions/1638337/the-best-way-to-synchronize-client-side-javascript-clock-with-server-date | |
// Improved by community and @jskowron | |
// Synchronize client-side clock with server time using an approximation of NTP | |
let serverTimeOffset = null; | |
function getServerTime(callback) { | |
if (serverTimeOffset === null) { | |
const scripts = document.getElementsByTagName("script"); | |
const currentScriptURL = scripts[scripts.length - 1].src; |