JavaScript getMilliseconds Function

JavaScript getMilliseconds function is one of the Date Function, which returns the number of Milliseconds on a given date.

JavaScript getMilliseconds Function Example

Use the JavaScript get Milliseconds to return the total number of milliseconds in the current date and time.

<!DOCTYPE html>
<html>
<head>
    <title> JavaScript Get Milliseconds Function </title>
</head>
<body>
    <h1> JavaScript getiMilliseconds Function Example </h1>
<script>
  var dt = Date();  
  document.write("Date and Time : " + dt);
  document.write("Milliseconds using getMilliseconds(): " + dt.getMilliseconds());
</script>
</body>
</html>
JavaScript getMilliseconds Function Example

Date and Time: Sun Nov 04 2018 16:08:08 GMT+0530 (Indian Standard Time)
Milliseconds using getMilliseconds(): 650

JavaScript get Milliseconds Function Example

In this getMilliseconds function example, we are finding the milliseconds from the custom date

<!DOCTYPE html>
<html>
<head>
    <title> JavaScript Get Milliseconds Function </title>
</head>
<body>
    <h1> JavaScript getMilliseconds Function Example </h1>
<script>
  var dt = Date("December 22, 2016 10:19:45.314");
  document.write("Date and Time : " + dt);
  document.write("Milliseconds using getMilliseconds(): " + dt.getMilliseconds());
</script>
</body>
</html>
JavaScript getMilliseconds Function 2

This JavaScript example returns the milliseconds from a custom date without Milliseconds (time). It returns 0 milliseconds.

<!DOCTYPE html>
<html>
<head>
    <title> JavaScript Get Milliseconds Function </title>
</head>
<body>
    <h1> JavaScript getMilliseconds Function Example </h1>
<script>
  var dt = Date("December 22, 1972");
  document.write("Date and Time : " + dt);
  document.write("Milliseconds using getMilliseconds(): " + dt.getMilliseconds());
</script>
</body>
</html>
JavaScript getMilliseconds Function Example

Date and Time: Fri Dec 22 1972 00:00:00 GMT+0530 (Indian Standard Time)
Milliseconds using getMilliseconds(): 0