.getUTCMilliseconds()

THE-Spellchecker's avatar
Published Jun 19, 2023Updated May 15, 2024
Contribute to Docs

The .getUTCMilliseconds() method returns the milliseconds for the provided Date object, according to universal time (not to be confused with the .getMilliseconds() method).

Syntax

myDate.getUTCMilliseconds()

The .getUTCMilliseconds() method will return an integer between 0 and 999, which represents the milliseconds for the given date, myDate, according to universal time.

The method will return NaN if the date is invalid.

Example

In the given example, .getUTCMilliseconds() is applied to the constant selectedDate and logged to the console.

const selectedDate = new Date('2020-08-09T01:32:28.412+01:00');
console.log(selectedDate.getUTCMilliseconds());

The code will result in the following output:

412

All contributors

Contribute to Docs

Learn JavaScript on Codecademy