Date.getMilliseconds()

Returns the milliseconds (from 0-999)

The getMilliseconds() method returns the milliseconds in the specified date according to local time.

var moonLanding = new Date('July 20, 69 00:20:18');
moonLanding.setMilliseconds(123);

console.log(moonLanding.getMilliseconds());
// expected output: 123

Syntax

dateObj.getMilliseconds()

Return value

A number, between 0 and 999, representing the milliseconds for the given date according to local time.

Examples

Using getMilliseconds()

The following example assigns the milliseconds portion of the current time to the variable milliseconds:

var today = new Date();
var milliseconds = today.getMilliseconds();

References

Contributors to this page

Uros Durdevic

Last updated