English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

The JavaScript toLocaleString() Method

 JavaScript Date Object

toLocaleString()The method converts the date to a string using the conventions of the operating system's locale.

toLocaleString()The method depends on the underlying operating system in formatting dates.

For example, in the United States, the month appears before the date (06/22/2018before, while in India, the date appears before the month (22/06/2018before).

Syntax:

date.toLocaleString()
var d = new Date();
var str = d.toLocaleString();
document.getElementById('result').innerHTML = str;
Test See‹/›

Browser Compatibility

All browsers fully support the toLocaleString() method:

Method
toLocaleString()YesYesYesYesYes

Technical Details

Return Value:A string representing the date and time according to the conventions of the operating system's locale
JavaScript Version:ECMAScript 1

 JavaScript Date Object