DateTimeFormat
Formats dates and times for a locale.
Intl provides locale-aware formatting and comparison. For dates and numbers, it is the professional display layer.
const date = new Date("2026-01-01T09:30:00Z");
new Intl.DateTimeFormat("nl-NL", {
dateStyle: "long"
}).format(date);
Dates, Time & Intl
Intl is a namespace for internationalization APIs. It includes DateTimeFormat, NumberFormat, RelativeTimeFormat, Collator, ListFormat and more.
For date lessons, Intl.DateTimeFormat is the key tool. It formats dates and times using locale, calendar, time zone and style options.
Intl helps avoid manual formatting rules. Instead of hard-coding punctuation, order and month names, you describe the display goal and let the platform format it.
Formats dates and times for a locale.
Formats numbers, percentages, units and currency-like output.
Formats relative text such as in 3 days.
Compares and sorts strings in locale-aware ways.
Examples
const formatter = new Intl.DateTimeFormat("en-GB", {
weekday: "long",
day: "numeric",
month: "long",
year: "numeric"
});
console.log(formatter.format(new Date("2026-01-01T09:30:00Z")));
const visible = `${day}/${month}/${year}`;
// This assumes one display order and one separator.
Code patterns
Dates and time zones become much easier when every example names the concept it represents: instant, local display, UTC output, calendar date, formatted text or zoned time.
Use dateStyle for readable date output.
const date = new Date("2026-01-01T09:30:00Z");
const formatter = new Intl.DateTimeFormat("nl-NL", {
dateStyle: "long"
});
console.log(formatter.format(date));
Use both dateStyle and timeStyle.
const formatter = new Intl.DateTimeFormat("en-GB", {
dateStyle: "medium",
timeStyle: "short",
timeZone: "UTC"
});
console.log(formatter.format(new Date("2026-01-01T09:30:00Z")));
Use RelativeTimeFormat for readable relative labels.
const formatter = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
console.log(formatter.format(-1, "day"));
console.log(formatter.format(3, "day"));
Collator handles language-aware comparisons.
const collator = new Intl.Collator("en", { sensitivity: "base" });
const items = ["zebra", "Apple", "áudio"];
console.log(items.sort(collator.compare));
Rules that matter
Date-time bugs usually start when storage format, calculation logic and user-facing display are treated as the same thing. Keep those responsibilities separate and the code becomes much easier to trust.
Manual formatting is rarely better than platform formatting.
Use a user locale or an explicit product locale.
DateTimeFormat can display a Date in named zones.
Create a formatter once when formatting many values.
Do not hand-build grammar for every language.
Locale-aware sorting is different from basic string comparison.
Production thinking
Users do not all read dates, numbers and words in the same format. Intl lets the interface speak their formatting language.
Locale-aware, complete text is easier to understand and less ambiguous for assistive technology users.
Production apps should centralize formatters and avoid hand-written formatting scattered through templates.
Visible dates should be understandable, while machine-readable dates should stay stable in metadata.
Live code lab
The preview runs inside an isolated iframe. The JavaScript is placed inside the HTML editor for now, so every example stays together and remains easy to understand.
Mini assignment
Practice assignment
Try it yourself
Self-check
Dates are full of traps. Explain the concept first, then run the code and check whether the output matches your mental model.