Why getMilliseconds ?
Javascript Date The getMilliseconds () method returns what is requested by the specified date. In the getMilliseconds () method, the desired value is milliseconds. Therefore, this method returns milliseconds. This value is a number between 0 and 999.
Syntax:
Date.getMilliseconds()
return: Returns the milliseconds in the specified date according to local time.
JavaScript getMilliseconds Examples
Example 1
The JavaScript getMilliseconds method can return the second of the current time.
var now = new Date();
console.log(now.getMilliseconds());
625
Example 2
The JavaScript getMilliseconds method returns the second of the desired time.
var date = new Date('November 26,12 15:22:18:243');
console.log(date.getMilliseconds());
243
Example 3
An error does not occur unless the number exceeds 999.
var date = new Date('July 21, 1983 01:15:00:999');
console.log(date.getMilliseconds());
999
Example 4
var date = new Date('July 21, 1983 01:15:00:1112');
console.log(date.getMilliseconds());
0
Browser Support
| Chrome | yes |
| Edge | yes |
| Firefox | 1 |
| Internet Explorer | yes |
| Opera | yes |
| Safari | yes |
| Android webview | yes |
| Chrome for Android | yes |
| Edge mobile | yes |
| Firefox for Android | 4 |
| Opera Android | yes |
Leave a comment