×

Index

JavaScript Tutorial

JavaScript Examples

CSS Tutorial

CSS Examples

Date getMilliseconds() method with example in JavaScript

JavaScript Date getMilliseconds() method: Here, we are going to learn about the getMilliseconds() method of Date class with Example in JavaScript.
Submitted by IncludeHelp, on March 04, 2019

JavaScript Date getMilliseconds() method

getMilliseconds() method is a Date's class method and it is used to get the only milliseconds from the current time.

It accepts nothing as the parameter and returns a value between 0 to 999.

Syntax

var dt = new Date();
dt.getMilliseconds();

Sample Input/Output

Input:
var dt = new Date();
dt.getMilliseconds();
    
Output:
538 (if the time is any_hours:any_minutes:any_seconds.538)

JavaScript code to get the milliseconds only from the current time using getMilliseconds() method

<html>
<head><title>JavaScipt Example</title></head>

<body>
<script>
	var dt = new Date(); //Date constructor 
	var ms = dt.getMilliseconds(); //getting Milliseconds from current time
	//printing Milliseconds
	document.write("Current Milliseconds is : " + ms);
</script>
</body>
</html>

Output

Current Milliseconds is : 538

JavaScript Date Object Methods »




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.