JavaScript Date getMilliseconds()方法 (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.
getMilliseconds()方法是Date的类方法,用于获取当前时间的毫秒数。
It accepts nothing as the parameter and returns a value between 0 to 999.
它不接受任何内容作为参数,并返回0到999之间的值。
Syntax:
句法:
var dt = new Date();
dt.getMilliseconds();
Examples:
例子:
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
JavaScript代码使用getMilliseconds()方法仅从当前时间获取毫秒数
<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