JavaScript getMilliseconds()Method

Date 对象参考手册JavaScript Date Object

Examples

Returns the milliseconds of a time according to local time:

var d = new Date();
var n = d.getMilliseconds();

nOutput:


Try it Yourself »

Definition and Usage

The getMilliseconds() method returns the milliseconds of a time.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the getMilliseconds() method


Syntax

Date.getMilliseconds()

Return Value

Type Description
Number The return value is an integer between 0 and 999, representing the milliseconds.

Technical Details

JavaScript Version: 1.3


More Examples

Examples

Return the number of milliseconds in a specified time:

var d = new Date("July 21, 1983 01:15:00:526");
var n = d.getMilliseconds();

nOutput:

526

Try it Yourself »
实例s

Display Time
How to use getHours(), getMinutes(), getSeconds(), and getMilliseconds() to display the current time.


Date 对象参考手册JavaScript Date Object

Other Extensions