How to get the current time in millisecond using JavaScript?


To get the current time in a millisecond, use the date getMilliseconds() method. JavaScript date getMilliseconds() method returns the milliseconds in the specified date according to local time. The value returned by getMilliseconds() is a number between 0 and 999.

Example

 You can try to run the following code to get the current time in milliseconds −

<html>
   <head>
      <title>JavaScript getMilliseconds() Method</title>
   </head>
   <body>
      <script>
         var dt = new Date( );
         document.write("getMilliseconds() : " + dt.getMilliseconds() );
      </script>
   </body>
</html>

Updated on: 19-Jun-2020

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements