English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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).
date.toLocaleString()
var d = new Date(); var str = d.toLocaleString(); document.getElementById('result').innerHTML = str;Test See‹/›
All browsers fully support the toLocaleString() method:
Method | |||||
toLocaleString() | Yes | Yes | Yes | Yes | Yes |
Return Value: | A string representing the date and time according to the conventions of the operating system's locale |
---|---|
JavaScript Version: | ECMAScript 1 |