JavaScript toString() Method
Example
Converts a Date object to a string:
var d=new Date();
var n=d.toString();
n Output result:
Try it »
Definition and Usage
The toString() method converts a Date object to a string and returns the result.
Note: This method is called automatically when a Date object needs to be displayed as a string.
Browser support





All major browsers support the toString() method
Syntax
Date
.toString()
Return Value
| Type | Description |
|---|---|
| String | Date and time output as a string |
Technical Details
| JavaScript version: | 1.0 |
|---|
JavaScript Date object