JavaScript Date toLocaleString()
Example
Get a date as string, using locale conventions:
const d = new Date();
let text = d.toLocaleString();
Try it Yourself »
Description
The toLocaleString() method returns a Date object as a string, using locale settings.
The default language depends on the locale setup on your computer.
Browser Support
toLocaleString()
is an ECMAScript1 (JavaScriopt 1997) feature.
It is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
Syntax
Date.toLocaleString(locales, options)
Parameter Values
Parameter | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
locales Try it |
Optional. Which language specific format to use. Click on the "Try it" button to see all values in action. Legal Values: ar-SA Arabic (Saudi Arabia)bn-BD Bangla (Bangladesh)bn-IN Bangla (India)cs-CZ Czech (Czech Republic)da-DK Danish (Denmark)de-AT Austrian Germande-CH "Swiss" Germande-DE Standard German (as spoken in Germany)el-GR Modern Greeken-AU Australian Englishen-CA Canadian Englishen-GB British Englishen-IE Irish Englishen-IN Indian Englishen-NZ New Zealand Englishen-US US Englishen-ZA English (South Africa)es-AR Argentine Spanishes-CL Chilean Spanishes-CO Colombian Spanishes-ES Castilian Spanish (as spoken in Central-Northern Spain)es-MX Mexican Spanishes-US American Spanishfa-IR Iranian (Iran)fi-FI Finnish (Finland)fr-BE Belgian Frenchfr-CA Canadian Frenchfr-CH "Swiss" Frenchfr-FR Standard French (especially in France)he-IL Hebrew (Israel)hi-IN Hindi (India)hu-HU Hungarian (Hungary)id-ID Indonesian (Indonesia)it-CH "Swiss" Italianit-IT Standard Italian (as spoken in Italy)ja-JP Japanese (Japan)ko-KR Korean (Republic of Korea)nl-BE Belgian Dutchnl-NL Standard Dutch (as spoken in The Netherlands)no-NO Norwegian (Norway)pl-PL Polish (Poland)pt-BR Brazilian Portuguesept-PT European Portuguese (as written and spoken in Portugal)ro-RO Romanian (Romania)ru-RU Russian (Russian Federation)sk-SK Slovak (Slovakia)sv-SE Swedish (Sweden)ta-IN Indian Tamilta-LK Sri Lankan Tamilth-TH Thai (Thailand)tr-TR Turkish (Turkey)zh-CN Mainland China, simplified characterszh-HK Hong Kong, traditional characterszh-TW Taiwan, traditional characters |
||||||||||||||||||||||||||||||
options | Optional. An object where you can set some properties. Legal properties:
|
Browser Support for Locales and Options
Chrome | IE / Edge | Firefox | Safari | Opera |
24 | 11 | 29 | 10 | 15 |
Technical Details
Return Value: | A String, representing the date and time as a string |
---|---|
JavaScript Version: | ECMAScript 1 |