Home »
jQuery »
jQuery DOM Manipulation Methods
jQuery event.timestamp Property
jQuery | event.timestamp Property: Learn about the jQuery event.timestamp Property with its usages, syntax, and examples.
Submitted by Pratishtha Saxena, on October 29, 2022
event.timestamp Property
An event is an action occurred by the user. Therefore, many functions and methods can be set according to those actions performed. When these actions are defined for an event interface, we term those as the event properties. There are various predefined event properties in jQuery. Here, let's discuss the event.timestamp Property.
The event.timestamp is a built-in property in jQuery. This property helps us to get the number of milliseconds passed since Jan 1, 1970. It returns the same when the event is triggered.
event.timestamp Property Syntax
event.timestamp
Since this is a property, it does not accept any parameters. It returns a numerical value for milliseconds. The example given below shows the implementation of event.timestamp property when the button provided is clicked.
jQuery event.timestamp Property Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<title>Document</title>
</head>
<body>
<h2>jQuery Event - Timestamp Property</h2>
<p>Get to know the milliseconds passed since <b>Jan 1, 1970</b>.</p>
<hr>
<button>Get Time Passed</button>
<hr>
<h3></h3>
</body>
<script type="text/javascript">
$(document).ready(function(){
$('button').click(function(){
$('h3').html('Milliseconds Passed: ' + event.timeStamp);
});
});
</script>
</html>
Output: