Home  >  Article  >  Web Front-end  >  JavaScript method getMilliseconds() that returns time milliseconds

JavaScript method getMilliseconds() that returns time milliseconds

黄舟
黄舟Original
2017-11-06 10:12:401827browse

Definition and Usage

getMilliseconds() method returns the milliseconds of time.

Syntax

dateObject.getMilliseconds()

Return value

The millisecond field of dateObject, displayed in local time. The return value is an integer between 0 ~ 999.

Tips and Notes:

Note: The value returned by getMilliseconds() 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.

Example

Example 1

In this example, we can get the milliseconds of the current time:

<script type="text/javascript">

var d = new Date()
document.write(d.getMilliseconds())

</script>

Output:

762

Example 2

In this example, we will extract the milliseconds field from the specific date and time:

<script type="text/javascript">

var born = new Date("July 21, 1983 01:15:00")
document.write(born.getMilliseconds())

</script>

Output:

0

javascript Date.getMilliseconds() method Returns the number of milliseconds in the specified date in local time. What is returned by getMilliseconds is a value between 0 and 999.

Returns the number of milliseconds in the specified date according to local time.
Example:

<html>
<head>
<title>JavaScript getMilliseconds Method</title>
</head>
<body>
<script type="text/javascript">
  var dt = new Date( );
  document.write("getMilliseconds() : " + dt.getMilliseconds() ); 
</script>
</body>
</html>

This will produce the following results:

getMilliseconds() : 578


The above is the detailed content of JavaScript method getMilliseconds() that returns time milliseconds. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn