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.

Latest Udacity Coupon Found:

Verified STAFF PICK

75% OFF COURSES

Udacity Black Friday Offer

The best time to save on Udacity courses is now - follow this coupon to access a 75% Udacity Black Friday discount & enjoy learning at a very low cost!

Expiration date: 30/11/2020
3176 People Used
Only 97 Left
Rating
5.0