JavaScript Date setTime() Method


Advertisements


Description

Javascript date setTime()method sets the Date object to the time represented by a number of milliseconds since January 1, 1970, 00:00:00 UTC.

Syntax

Its syntax is as follows −

Date.setTime(timeValue)

Note − Parameters in the bracket are always optional.

Parameter Detail

timeValue − An integer representing the number of milliseconds since 1 January 1970, 00:00:00 UTC.

Example

Try the following 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>

Output

Thu Jan 01 1970 06:53:20 GMT+0530 (India Standard Time) 

javascript_date_object.htm