As is well known, the Javascript Date object provides a method getTime() to return the number of milliseconds since 1/1/1970. However, I'm seeing a problem when such timestamps are used in calculations with DOM Event timestamps in Firefox.

It appears that the DOM Event timeStamp field in Firefox is the number of milliseconds since system start. On Windows boxes, at least, it actually appears to be the result of the system call GetTickCount() (rather than QueryPerformanceCounter, which is close but drifts from the timeStamp slowly).

The strange thing is when I tried to create my own event and dispatch it then read the timestamp (createEvent, dispatchEvent) in Firefox JS, I get a valid 1/1/1970 timestamp.

So timestamps I create are calculation compatible with getTime(), but those that originate from actual mouse and keyboard events are not, and have this other "time since system start" timestamp.

Is there any way in about:config in Firefox to change this so we get 1/1/1970 timestamps for all events? The reason I was creating my own event was so I could subtract from the getTime() value to yield an offset to allow the DOM event timestamp to be converted to a 1/1/1970 timestamp but that plan failed because the different timestamps didn't show up in events I created myself. (Yeah I know there's an issue with rollover as I believe GetTickCount is only 32 bits but we can address that later if need be.)

Member Avatar for stbuchok

Can you give a full code example as to what you are talking about?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.