• JavaScript Video Tutorials

JavaScript - Date parse() Method



Description

Javascript date parse() method takes a date string and returns the number of milliseconds since midnight of January 1, 1970.

Syntax

Its syntax is as follows −

Date.parse(datestring)

Note − Parameters in the bracket are always optional.

Parameter Details

datestring − A string representing a date

Return Value

Number of milliseconds since midnight of January 1, 1970.

Example

Try the following example.

<html>
   <head>
      <title>JavaScript parse Method</title>
   </head>
   
   <body>      
      <script type = "text/javascript">
         var msecs = Date.parse( "Aug 28, 2008 23:30:00" );
         document.write( "Number of milliseconds from 1970: " + msecs );
      </script>     
   </body>
</html>

Output

Number of milliseconds from 1970: 1219946400000
javascript_date_object.htm
Advertisements