jQuery timeStamp: Main Tips
- The event
timeStamp
property is used to return the number of milliseconds passed since January 1st, 1970, until the execution of an event. - Jquery
timeStamp
helps monitor event performance.
Usage of event.timeStamp
The event.timeStamp
property indicates the time passed from January 1st, 1970, to a specific event in milliseconds. You can also apply this property to check performance of events: use it in two places of the code, and compare the results.
Tip: receive the current time inside an event handler by applying (new Date).getTime() method.
As you click the button provided, this example shows how many seconds passed since the onclick event occured:
Example
$("button").click((event) => {
$("div").text(event.timeStamp);
});
Warning: due to a bug found in 2004, this value does work properly in Firefox. You cannot get the jQuery timestamp on when an event was created.