0Pricing
JavaScript Academy · Lesson

Formatting Dates and Times

Display dates with Intl.DateTimeFormat.

Intl.DateTimeFormat

Intl.DateTimeFormat formats Date objects according to a locale, replacing brittle manual string building.

const dtf = new Intl.DateTimeFormat("en-US");
console.log(dtf.format(new Date("2026-05-29"))); // "5/29/2026"

Locale Differences

Date order differs by region: US is month/day/year, much of Europe is day/month/year.

const d = new Date("2026-05-29");
console.log(new Intl.DateTimeFormat("en-US").format(d)); // 5/29/2026
console.log(new Intl.DateTimeFormat("en-GB").format(d)); // 29/05/2026

All lessons in this course

  1. Formatting Numbers and Currency
  2. Formatting Dates and Times
  3. Relative Time and Plurals
  4. Locale-Aware Sorting
← Back to JavaScript Academy