What is date object in JavaScript?

JavascriptWeb DevelopmentFront End Technology

The Date object is a datatype built into the JavaScript language. Date objects are created with new Date( ) as shown below −

new Date( )
new Date(milliseconds)
new Date(datestring)
new Date(year,month,date[,hour,minute,second,millisecond ])

Example

You can try to run the following code to implement Date object in JavaScript −

Live Demo

<html>
   <head>
      <title>JavaScript Dates</title>
   </head>
   <body>
      <script>
         var date = new Date();
         document.write("dt.constructor is : " + date.constructor);
      </script>
   </body>
</html>

Output

dt.constructor is : function Date() { [native code] }
raja
Published on 12-Feb-2018 13:35:07
Advertisements