How do you format a date in JavaScript?

← JavaScript answers

Use Intl.DateTimeFormat (or toLocaleDateString) with options for a localized format, or toISOString() for a machine-readable one.

const d = new Date("2026-03-09T14:30:00Z");
 
d.toLocaleDateString("en-US", { year: "numeric", month: "long", day: "numeric" });
// "March 9, 2026"
 
new Intl.DateTimeFormat("de-DE", { dateStyle: "medium", timeStyle: "short", timeZone: "UTC" }).format(d);
// "09.03.2026, 14:30"
 
d.toISOString(); // "2026-03-09T14:30:00.000Z"

Intl is built into every modern browser and Node.js, so you rarely need a date library just for display. Always pass a timeZone when the output must be the same for every user, because the default is the user's local time zone.

Start debugging smarter today

Try Bugsee for free — no commitments, no hidden fees.

Free sign upLive demoNo credit card required