JavaScript toString()Method
Example
Convert a Date object to a string:
var d=new Date();
var n=d.toString();
var n=d.toString();
nOutput:
Try it yourself »
Definition and Usage
The toString() method converts a Date object to a string and returns the result.
Note:This method is automatically called 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 as a string output |
Technical Details
| JavaScript Version: | 1.0 |
|---|
Other Extensions
JavaScript Date Object