Date.prototype.toLocaleDateString, toLocaleTimeString and toLocaleString
A full Intl.DateTimeFormat behind three method calls. Every hand-rolled date format is an attempt to reimplement part of this, usually for one locale only.
Demo
The same instant, five conventions. en-US puts the month first and en-GB the day, which is precisely the ambiguity that makes 03/04 unreadable without knowing the locale — and why hand-rolling a slash format is always wrong for somebody. The sv-SE case is a useful trick: Swedish convention happens to be ISO-like, so it is the shortest way to get a LOCAL calendar date in YYYY-MM-DD form. Note the demo pins timeZone to UTC; without that, the output would also depend on where each reader is sitting.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| locales | string | string[] | no (host default) | A BCP 47 tag such as "en-GB" or "de-DE". Omitted, the runtime locale is used — which differs between your machine and your users. |
| options | object | no ({}) | Intl.DateTimeFormat options — dateStyle, timeStyle, weekday, month, day, year, hour, minute, timeZone, hour12. Setting timeZone is what makes output reproducible. |
Return value
string — The date formatted for the given locale. toLocaleDateString gives the date part, toLocaleTimeString the time part, toLocaleString both.
Common patterns
d.toLocaleDateString('en-GB', {dateStyle: 'long'});
d.toLocaleDateString('sv-SE'); // '2026-03-15'
const f = new Intl.DateTimeFormat('en-GB', {dateStyle: 'short'}); rows.map(r => f.format(r.at));
Examples
Pitfalls
d.toLocaleDateString()
d.toLocaleDateString('en-GB', {timeZone: 'UTC'})
Date.parse(new Date('2026-03-15T12:00:00Z').toLocaleDateString('de-DE'))
const stored = d.toISOString();
rows.map(r => r.at.toLocaleDateString("en-GB"))
const f = new Intl.DateTimeFormat("en-GB"); rows.map(r => f.format(r.at));
new Date('2026-03-15T13:00:00Z').toLocaleTimeString('en-US', {timeZone: 'UTC'})
new Date('2026-03-15T13:00:00Z').toLocaleTimeString('en-GB', {timeZone: 'UTC', hour12: false})
When to use
- Any date shown to a person
- Rendering in a specific named timezone, via the timeZone option
- Month and weekday names, without a lookup table
- Getting a LOCAL calendar day, via the sv-SE trick
- Storing or transmitting → toISOString
- Formatting many dates → Intl.DateTimeFormat, reused
- Output you will parse back → keep the original
- Reproducible tests → pin both locale and timeZone
Notes
FAQ
Use the sv-SE locale, whose convention is ISO-like. Slicing toISOString gives the UTC day, which can be a day out from the reader local date.
d.toLocaleDateString('sv-SE'); // local day d.toISOString().slice(0, 10); // UTC day