JavaScript toString()Method

Date 对象参考手册JavaScript Date Object

Example

Convert a Date object to a string:

var d=new Date();
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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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


Date 对象参考手册JavaScript Date Object

Other Extensions