Latest web development tutorials

JavaScript toLocaleString () method

Date Object Reference JavaScript Date Object

Examples

According to the local time of the Date object to a string:

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

n output:


try it"

Definition and Usage

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


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support toLocaleString () method


grammar

Date.toLocaleString()

return value

Type 描述
String 日期和时间以字符串形式输出。

technical details

JavaScript version: 1.0


Date Object Reference JavaScript Date Object