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