HTML | DOM timeStamp Event Property

The timeStamp Event property is used to get the timestamp of when a particular event is created. It basically returns the difference in time (in milliseconds) between the time of event created by the browser and January 1, 1970.

It is a read-only property.

Syntax:

event.timeStamp

Return Value: : This event returns the number of milliseconds since January 1, 1970 and when the event is triggered.

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>DOM timeStamp Event Property</title>
    </head>
  
    <body onwheel="Geeks(event)" 
          style="text-align:center">
      
        <h1 style="color: green;">
            GeeksforGeeks
        </h1>
          
        <h2>DOM timeStamp Event Property</h2>
          
        <p onclick="Geeks(event)">
            The click event occurred 
            <span id = "s" style="color:green">
                unknown
            </span
            milliseconds after January 1, 1970.
        </p
          
        <script>
            function Geeks(event) {
                var doc = event.timeStamp;
                document.getElementById("s").innerHTML = doc;
            }
        </script>
    </body>
</html>                    

chevron_right


Output:
Before clicking the paragraph:
timestamp
After clicking the paragraph:
timestamp
Supported Browsers: The browser supported by timeStamp Event property are listed below:

  • Apple Safari
  • Google Chrome
  • Firefox
  • Opera
  • Internet Explorer 9.0


My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.