Skip to content

Instantly share code, notes, and snippets.

@filiptronicek
Last active November 27, 2020 12:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save filiptronicek/89fb96ea5adadb20009d03b9fe943ad3 to your computer and use it in GitHub Desktop.
Get time difference between server and client
const timestamp = Date.now();
fetch(`https://time.filiptronicek.workers.dev/?ts=${timestamp}`).then(f => f.json()).then(f => {
const nowstamp = Date.now()
console.table({adjusted: Math.round(f.result.ms - (nowstamp - timestamp) / 2), raw: f.result.ms})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment