JavaScript toLocaleString(): Localized Date and Time

Date.prototype.toLocaleString() returns a locale-aware date-and-time string. By default it uses the environment’s locale and local time zone; you can supply a locale, a named time zone, and detailed formatting options.

Syntax:

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

Example:

const date = new Date("2026-09-10T12:30:00Z");
console.log(date.toLocaleString("en-IN", { timeZone: "Asia/Kolkata" }));

Default toLocaleString() Output Top ↑

With no arguments, the output is based on the runtime’s default locale and time zone, so punctuation, field order and hour cycle can differ between users.

const now = new Date();
console.log(now.toLocaleString());

Choosing a Locale Top ↑

const date = new Date("2026-09-10T12:30:00Z");
console.log(date.toLocaleString("en-IN"));
console.log(date.toLocaleString("en-US"));
console.log(date.toLocaleString("fr-FR"));

Selecting Date and Time Components Top ↑

const options = {
  weekday: "short",
  year: "numeric",
  month: "short",
  day: "2-digit",
  hour: "2-digit",
  minute: "2-digit"
};
console.log(new Date().toLocaleString("en-IN", options));

Using dateStyle and timeStyle Top ↑

For common user-facing formats, dateStyle and timeStyle are more concise than listing every component.

const date = new Date();
console.log(date.toLocaleString("en-IN", {
  dateStyle: "long",
  timeStyle: "short"
}));

Displaying a Named Time Zone Top ↑

const instant = new Date("2026-09-10T12:30:00Z");
console.log(instant.toLocaleString("en-IN", {
  timeZone: "Asia/Kolkata",
  dateStyle: "medium",
  timeStyle: "long"
}));

Using a named zone is safer than manually adding fixed offsets when daylight-saving or historical offset rules may apply.

Choosing 12-Hour or 24-Hour Time Top ↑

const date = new Date();
console.log(date.toLocaleString("en-IN", { hour: "2-digit", minute: "2-digit", hour12: false }));

Reusing Intl.DateTimeFormat Top ↑

When formatting many values with identical settings, reuse one formatter.

const formatter = new Intl.DateTimeFormat("en-IN", { dateStyle: "medium", timeStyle: "short" });
console.log(formatter.format(new Date()));

Related Date String Methods Top ↑

Common toLocaleString() Mistakes Top ↑

  • Assuming default formatting is identical on every device.
  • Parsing localized output as if it were a stable storage format.
  • Using fixed numeric time-zone offsets for locations that observe DST.
  • Constructing a new formatter repeatedly in a large rendering loop.

Next: toDateString() Date Reference




Subscribe to our YouTube Channel here



plus2net.com










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer