JavaScript toLocaleDateString()Method

Date 对象参考手册JavaScript Date Object

Example

Convert the date portion of a Date object to a string according to local time:

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

nOutput:


Try it Yourself »

Definition and Usage

The toLocaleDateString() method converts the date portion of a Date object into a string according to local time and returns the result.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the toLocaleDateString() method


Syntax

Date.toLocaleDateString()

Return Value

Type Description
String A string representation of the date portion of a date Object, expressed in the local time zone and formatted according to local rules.

Technical Details

JavaScript Version: 1.0


Date 对象参考手册JavaScript Date Object

Other Extensions