Black friday

Save big!

All courses under $5 - for a limited time!

Code has been added to clipboard!

jQuery timeStamp: Learn to Track Event Performance

Reading time 1 min
Published Jan 8, 2018
Updated Sep 27, 2019

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.