JavaScript Date toLocaleString() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Date

Definition

Date.prototype.toLocaleString() returns a language-sensitive string for both the date and time of a Date (local timezone by default). With Intl support, it delegates to Intl.DateTimeFormat.

Remember
date.toLocaleString()
date.toLocaleString(locales)
date.toLocaleString(locales, options)

→ "20/12/2012, 03:00:00"     (en-GB + timeZone: "UTC")
→ "Invalid Date"             (if the Date is invalid)

toLocaleDateString()  → date only
toLocaleTimeString()  → time only
toString()            → fixed engine datetime text

Syntax

Call date.toLocaleString. Start with this line.

JavaScript
date.toLocaleString(locales?, options?)
CallWhat it does
date.toLocaleString(locales?, options?)Primary signature.
date.toLocaleString(...)Call with the arguments your case needs.

Built into JavaScript. Call toLocaleString(...) on a Date instance — no import required.

Library declarations
JavaScript
date.toLocaleString(locales?, options?)

Parameters

ParameterDescription
localesOptional. BCP 47 tag or array of tags
optionsOptional. dateStyle, timeStyle, timeZone, hour12, …

Return Value

Return ValueDescription
*The value returned by date.toLocaleString().

JavaScript Examples

Example 1 — Same Instant in Two Locales (UTC)

Pin timeZone: "UTC" so the clock part stays predictable across machines.

JavaScript
const event = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
const utc = { timeZone: "UTC" };

console.log(event.toLocaleString("en-GB", utc));
// "20/12/2012, 03:00:00"

console.log(event.toLocaleString("ko-KR", utc));
// "2012. 12. 20. 오전 3:00:00"
Try It Yourself

How It Works

  1. Build a UTC instant. Date.UTC(2012, 11, 20, 3, 0, 0) is Dec 20, 2012 at 03:00 UTC.
  2. Fix the zone. timeZone: "UTC" stops local offset from shifting the clock.
  3. Format for Britain. Day/month order and 24-hour time.
  4. Format for Korea. Year-first order and a 12-hour period marker.

Example 2 — dateStyle and timeStyle

Use style presets instead of listing every field.

JavaScript
const event = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));

console.log(event.toLocaleString("en-US", {
  dateStyle: "medium",
  timeStyle: "short",
  timeZone: "UTC"
}));
// "Dec 20, 2012, 3:00 AM"
Try It Yourself

How It Works

  1. Reuse the same UTC instant. One absolute moment in time.
  2. Pick dateStyle. "medium" is a compact calendar label.
  3. Pick timeStyle. "short" keeps hours/minutes without seconds.
  4. Stay in UTC. The printed clock matches 03:00 UTC → 3:00 AM in en-US.

Example 3 — Guard Against Invalid Dates

Check getTime() before formatting user input.

JavaScript
const bad = new Date("not-a-date");

if (Number.isNaN(bad.getTime())) {
  console.log("Bad input");
} else {
  console.log(bad.toLocaleString("en-US"));
}
// without the guard: "Invalid Date"
Try It Yourself

How It Works

  1. Create an invalid Date. Bad input yields a NaN time value.
  2. Detect early. Number.isNaN(bad.getTime()) is true.
  3. Show a clear message. Prefer "Bad input" over a confusing label.
  4. Without a guard. toLocaleString() returns the string "Invalid Date".

Browser & Runtime Support

Date.prototype.toLocaleString() itself dates to ES1. The locales and options parameters require the Intl API (widely available in modern browsers and Node.js).

✓ Baseline · Intl

Date.prototype.toLocaleString()

Basic method: everywhere Date exists. Locales/options: Chrome, Firefox, Safari, Edge, and modern Node.js with full Intl data.

98% Modern Intl support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Date.toLocaleString() Excellent

Bottom line: Safe for modern UI. Feature-detect with typeof Intl !== "undefined" && Intl.DateTimeFormat if you must support very old engines. See also the MDN toLocaleString() reference.

Frequently Asked Questions

A language-sensitive string for both date and time in the local timezone by default (for example "20/12/2012, 03:00:00" in en-GB with timeZone UTC). It is for display, not API storage.
toLocaleString() includes date and time. toLocaleDateString() is date-only. Use toLocaleTimeString() when you need time alone.
Yes. Options like { dateStyle: "medium", timeStyle: "short" } format both parts without listing every field.
Local timezone by default. Pass timeZone (for example "UTC" or "Europe/Berlin") to format the same instant in another zone.
No. Engines may insert non-breaking spaces or bidirectional marks. Treat the output as display text; use toISOString() for interchange.
It returns the string "Invalid Date". Validate with Number.isNaN(date.getTime()) before showing labels in UI.

Next: toLocaleTimeString()

Learn how to format locale-aware clock time without the calendar date.

toLocaleTimeString() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful