Latest web development tutorials

JavaScript toLocaleDateString () method

Date Object Reference JavaScript Date Object

Examples

According to local time, the date portion of a Date object converted to a string:

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

n output:


try it"

Definition and Usage

toLocaleDateString () method can be based on the local time of the date portion of a Date object converted to a string and returns the result.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support toLocaleDateString () method


grammar

Date.toLocaleDateString()

return value

Type 描述
String date Object 的日期部分的字符串表示,以本地时间区表示,并根据本地规则格式化。

technical details

JavaScript version: 1.0


Date Object Reference JavaScript Date Object