Home > Web Front-end > JS Tutorial > Detailed explanation of the use of Date.UTC() method in JavaScript_Basic knowledge

Detailed explanation of the use of Date.UTC() method in JavaScript_Basic knowledge

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 15:55:28
Original
1436 people have browsed it

This method takes a date and returns the number of milliseconds since midnight universal time on January 1, 1970.
Grammar

Date.year,month,day,[hours,[minutes,[seconds,[ms]]])

Copy after login

Note: Data in brackets are optional

Here are the details of the parameters:

  • year: four digits representing the year
  • month: an integer between 0 and 11, indicating the month
  • day: an integer between 1 and 31, representing the date
  • hours: an integer between 0 and 23, indicating the hour
  • minutes: an integer between 0 and 59, representing minutes
  • seconds: an integer between 0 and 59, representing seconds
  • ms: an integer between 0 and 999, representing milliseconds

Return value:

Number of milliseconds since midnight on January 1, 1970
Example:

<html>
<head>
<title>JavaScript UTC Method</title>
</head>
<body>
<script type="text/javascript">
  var msecs = Date.UTC(2008,9,6);
  document.write( "Number of milliseconds from 1970: " + msecs ); 
</script>
</body>
</html>

Copy after login

This will produce the following results:

Number of milliseconds from 1970: 1223251200000 

Copy after login

Related labels:
Statement of this Website
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
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template