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

JavaScript toLocaleDateString() 方法

 JavaScript Date Object

toLocaleDateString()返回一个表示该日期对象日期部分的字符串,该字符串格式与系统设置的地区关联(locality sensitive)。

toLocaleDateString()The method depends on the underlying operating system for formatting dates.

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

Syntax:

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

Browser Compatibility

All browsers fully support the toLocaleDateString() method:

Method
toLocaleDateString()YesYesYesYesYes

Technical Details

Return Value:A string, represented according to the conventions of the operating system's locale setting for the 'date' part
JavaScript Version:ECMAScript 1

 JavaScript Date Object