JavaScript - Date() Method

Description

Javascript Date() method returns today's date and time and does not need any object to be called.

Syntax

Its syntax is as follows −

Date()

Return Value

Returns today's date and time.

Example

Try the following example.

<html>
   <head>
      <title>JavaScript Date Method</title>
   </head>
   
   <body>
   
      <script type="text/javascript">
         var dt = Date();
         document.write("Date and Time : " + dt ); 
      </script>
      
   </body>
</html>

Output

Date and Time : Sun Jul 15 2018 14:30:50 GMT-0500 (Central Daylight Time)