How can I write a script to detect when a user changes their system time in JS?
use performance.now()
to get duration, which will be independent of system clock
see https://developer.mozilla.org/en-US/docs/Web/API/Performance/now
var t0 = performance.now();
doSomething();
var t1 = performance.now();
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.");
And then you can compare performance.now()
elapsed with Date.now()
elapsed to see whether they are diff too much.