Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript toString() Method

JavaScript toString() Method

Date Object Reference JavaScript Date object

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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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

Date Object Reference JavaScript Date object