JavaScript Date getMilliseconds()

The JavaScript date getMilliseconds() method is used to get the integer value between 0 and 999 that represents the milliseconds on the basis of local time.

Syntax:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
dateObj.getMilliseconds()
dateObj.getMilliseconds()
dateObj.getMilliseconds()

Return:
An integer value between 0 and 999.

Example:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!DOCTYPE html>
<html>
<body>
<script>
var d = new Date("March 16, 2018 13:34:45:500");
var n = d.getMilliseconds();
document.writeln(n)
</script>
</body>
</html>
<!DOCTYPE html> <html> <body> <script> var d = new Date("March 16, 2018 13:34:45:500"); var n = d.getMilliseconds(); document.writeln(n) </script> </body> </html>
<!DOCTYPE html>
<html>
<body>
<script>
var d = new Date("March 16, 2018 13:34:45:500");
var n = d.getMilliseconds();
document.writeln(n)
</script>
</body>
</html>