C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript Date toString() methodThe JavaScript date toString() method returns a Date object in the form of string. SyntaxThe toString() method is represented by the following syntax: dateObj.toString() ReturnA string representing the specified date. JavaScript Date toString() method exampleHere, we will understand toString() method through various examples. Example 1Let's see an example to print the current date in the form of string. <script> var date=new Date(); document.writeln(date.toString()); </script> Output: Tue Aug 07 2018 16:57:22 GMT+0530 (India Standard Time) Example 2Let's see an example to print the specified date in the form of string. <script> var date=new Date(1947, 7, 15, 20, 22, 10); document.writeln(date.toString()); </script> Output: Fri Aug 15 1947 20:22:10 GMT+0530 (India Standard Time)
Next TopicJavaScript Date
|