JavaScript - Date getTime() Method


Advertisements


Description

Javascript date getTime() method returns the numeric value corresponding to the time for the specified date according to universal time. The value returned by the getTime method is the number of milliseconds since 1 January 1970 00:00:00.

You can use this method to help assign a date and time to another Date object.

Syntax

Its syntax is as follows −

Date.getTime()

Return Value

Returns the numeric value corresponding to the time for the specified date according to universal time.

Example

Try the following example.

<html>
   <head>
      <title>JavaScript getTime Method</title>
   </head>
   
   <body>
   
      <script type="text/javascript">
         var dt = new Date( "December 25, 1995 23:15:20" );
         document.write("getTime() : " + dt.getTime() ); 
      </script>
      
   </body>
</html>

Output


javascript_date_object.htm