Home  >  Article  >  Web Front-end  >  Introduction to the use of setTime() method in JavaScript_Basic knowledge

Introduction to the use of setTime() method in JavaScript_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 15:55:361441browse

The javascript Date.setTime() method sets the time represented by the Date object in milliseconds since January 1, 1970 00:00:00 UTC.
Grammar

Date.setTime(timeValue)

Note: The data inside and outside the brackets are optional

Here are the details of the parameters:

  • timeValue: Represents an integer (number of milliseconds) since January 1970 00:00:00 UTC.

Return value:

  • NA

Example:

<html>
<head>
<title>JavaScript setTime Method</title>
</head>
<body>
<script type="text/javascript">
  var dt = new Date( "Aug 28, 2008 23:30:00" );
  dt.setTime( 5000000 );
  document.write( dt ); 
</script>
</body>
</html>

This will produce the following results:

Thu Jan 1 06:53:20 UTC+0530 1970 

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