Definition and Usage
The getUTCMilliseconds() method returns the milliseconds of time based on Universal Time (UTC).
Syntax
dateObject.getUTCMilliseconds()
Return value
When dateObject is expressed in universal time, return its millisecond field, which is an integer between 0 ~ 999 .
Tips and Notes:
Note: The value returned by getUTCMilliseconds() is a three-digit number. However, the return value is not always three digits. If the value is less than 100, only two digits are returned. If the value is less than 10, only one digit is returned.
Note: This method is always used in conjunction with a Date object.
Tip: For more information about Universal Coordinated Time (UTC), please refer to Baidu Encyclopedia.
Example
Example 1
In this example, we will get the UTC milliseconds of the current time:
<script type="text/javascript"> var d = new Date() document.write(d.getUTCMilliseconds()) </script>
Output:
651
Example 2
Here we will extract UTC milliseconds from a specific date and time:
<script type="text/javascript"> var born = new Date("July 21, 1983 01:15:00") document.write(born.getUTCMilliseconds()) </script>
Output:
0
Example:
The following example prints the millisecond portion of the current time variable hrs.
<html> <head> <title>JavaScript getUTCMilliseconds Method</title> </head> <body> <script type="text/javascript"> var dt = new Date(); document.write("getUTCMilliseconds() : " + dt.getUTCMilliseconds() ); </script> </body> </html>
This will produce the following results for India time zone:
getUTCMilliseconds() : 453
The above is the detailed content of The JavaScript method getUTCMilliseconds() can return the time in milliseconds according to Universal Time (UTC). For more information, please follow other related articles on the PHP Chinese website!