Latest web development tutorials

JavaScript toString () method

Date Object Reference JavaScript Date Object

Examples

The Date object to a string:

var d=new Date();
var n=d.toString();

n output:


try it"

Definition and Usage

toString () method of the Date object to a string and returns the result.

Note: When theDate object needs to appear as a character string this method is called automatically.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support toString () method


grammar

Date.toString()

return value

Type 描述
String 日期和时间作为字符串输出

technical details

JavaScript version: 1.0


Date Object Reference JavaScript Date Object