JavaScript Date toLocaleString() Method
- Previous Page toLocaleTimeString()
- Next Page toString()
- Go to Parent Layer JavaScript Date Reference Manual
Definition and Usage
toLocaleString()
Methods use locale settings to convert Date objects to strings.
The default language depends on the regional settings on your computer.
Example
Use locale conventions to convert Date objects to strings:
var d = new Date(); var n = d.toLocaleString();
Syntax
Date.toLocaleString(locales, options)
Parameter Value
Parameter | Description |
---|---|
locales |
Optional. To use language-specific formats. Click the "Try it" button to view all running values. Valid Values:
|
options |
Optional. An object that can set some properties. Valid Attributes are listed in the following table: |
Valid Attributes | Valid Values: |
---|---|
dateStyle |
|
timeStyle |
|
localeMatcher |
|
timeZone |
|
hour12 |
|
hourCycle |
|
formatMatcher |
"basic" "best-fit" (Default) |
weekday |
|
year |
|
month |
|
day |
|
hour |
|
minute |
|
second |
|
timeZoneName |
|
Technical Details
Return Value: | A string representing a date and time in string format. |
---|---|
JavaScript Version: | ECMAScript 1 |
Browser Support
Method | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
toLocaleString() | Support | Support | Support | Support | Support |
- Previous Page toLocaleTimeString()
- Next Page toString()
- Go to Parent Layer JavaScript Date Reference Manual