Home > Article > Web Front-end > Detailed explanation of the use of Date.UTC() method in JavaScript_Basic knowledge
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]]])
Note: Data in brackets are optional
Here are the details of the parameters:
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>
This will produce the following results:
Number of milliseconds from 1970: 1223251200000