ADBlock is blocking some content on the site

ADBlock errore

Would event.timeStamp and Date.getTime have the same reference?

StackOverflow https://stackoverflow.com/questions/18165298


Would event.timeStamp and Date.getTime() return same values if taken at the exact same time?

For instance, could I use getTime() in order to calculate how much time passed since an event occurred, or might it happen that the 2 use different epoch / references?


No, they're always on the same reference, that is UTC, which is the time zone of all date internal storages.

You can also use Date.now().


It depends on the browser.

Using the following HTML document I got different results using different browsers:

<!DOCTYPE html>

<div id="foo">onclick delay:</div>
<button onclick='var n=document.getElementById("foo"); n.innerHTML="onclick delay: "+((new Date).getTime()-event.timeStamp)+"ms"'>Click</button>


The delay printed on screen is:

Firefox: large number

IE: -4ms .. 0ms

Chrome: 0ms .. 2ms

Opera: 0ms .. 2ms

=> You cannot really use it if your code should work in different browsers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow