Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome is reporting a wrong event.timeStamp value (6 digit or negative values)

I have the following code

$("p").on( "mousemove", function(event) {
   $("p").text(event.timeStamp);
});

It returns a 9 digit positive value in both Firefox and Edge but in Chrome only a six digit decimal number. My chrome version is 43. What is wrong here?

EDIT : I updated my Chrome version but I still get either negative time values or a six digit number. My Chrome version is 48 now. I am using Window 10 64 bit if that matters.

EDIT 2 : When I reload my page, for a brief period of time the value is positive. After that it becomes negative. The negative value decreases with time and finally, it becomes positive and keeps increasing.

like image 397
SanJeet Singh Avatar asked Feb 01 '16 04:02

SanJeet Singh


2 Answers

In chrome (version 48/49... m) the event.timeStamp return a float value, something like 18000.123..

I have simply stopped using event.timeStamp and instead I have put Date.now(), which is not as precise but avoid this issue.

reference

like image 94
Mohammad Imran Avatar answered Nov 15 '22 00:11

Mohammad Imran


It looks to me like event.timeStamp is now milliseconds since page load rather than milliseconds since January 1st 1970 00:00:00 (as defined in the specification).

I check this by comparing event.timeStamp to performance.now() which are the same.

like image 24
Woodgnome Avatar answered Nov 15 '22 00:11

Woodgnome