Javascript Reference - JavaScript toLocaleString() Method








Date type's toLocaleString() returns the date and time in a locale format.

Browser Support

toLocaleString() Yes Yes Yes Yes Yes

Syntax

dateObject.toLocaleString();

Return Value

A string representing the date and time as a string.





Example


var aDate = new Date(Date.UTC(2000, 0)); 
console.log(aDate);
console.log(aDate.toLocaleString());

The code above generates the following result.