JavaScript toLocaleString()Method

Date 对象参考手册JavaScript Date Object

Examples

Convert the Date object to a string according to local time:

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

nOutput:


Try it Yourself »

Definition and Usage

The toLocaleString() method converts a Date object to a string according to local time and returns the result.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the toLocaleString() method.


Syntax

Date.toLocaleString()

Return Value

Type Description
String The date and time are output as a string.

Technical Details

JavaScript Version: 1.0


Date 对象参考手册JavaScript Date Object

Other Extensions