How to convert a JavaScript date object to a string?

JavascriptWeb DevelopmentFront End Technology

To convert a JavaScript date object to a string, use the toString() method. This method returns a string representing the specified Date object.

Example

You can try to run the following code to convert a date object to a string −

<html>
   <head>
      <title>JavaScript toString() Method</title>
   </head>
   <body>
      <script>
         var dateobject = new Date(2017, 9, 24, 14, 39, 7);
         stringobj = dateobject.toString();
         document.write( "String Object : " + stringobj );
      </script>
   </body>
</html>
raja
Published on 16-Feb-2018 19:28:37
Advertisements