JavaScript Date getUTCMilliseconds()
Examples
Get the UTC milliseconds:
const d = new Date();
let ms = d.getUTCMilliseconds();
Try it Yourself »
Get the UTC milliseconds from a specific date:
const d = new Date("July 21, 1983 01:15:00.250");
let ms = d.getUTCMilliseconds();
Try it Yourself »
More examples below.
Description
getUTCMilliseconds()
returns the milliseconds (0 to 999) of a date.
getUTCMilliseconds()
returns the milliseconds according to UTC.
Notes
UTC (Universal Time Coordinated) is the time set by the World Time Standard.
UTC time is the same as GMT time (Greenwich Mean Time).
All JavaScript getUTC methods assume that the date is of local time.
Syntax
Date.getUTCMilliseconds()
Parameters
NONE |
Return Value
Type | Description |
A number | The milliseconds of the date (0 to 999). |
Browser Support
getUTCMilliseconds()
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
More Examples
Use all getUTC methods to display the universal time:
function addZero(x, n) {
while (x.toString().length < n) {
x = "0" + x;
}
return x;
}
const d = new Date();
let h = addZero(d.getUTCHours());
let m = addZero(d.getUTCMinutes());
let s = addZero(d.getUTCSeconds());
let ms = addZero(d.getUTCMilliseconds());
let time = h + ":" + m + ":" + s;
Try it Yourself »
Related Pages:
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.