---
title: "How do you format a date in JavaScript?"
description: "Format dates in JavaScript with Intl.DateTimeFormat and toLocaleDateString, or build an ISO string without any library."
url: "https://bugsee.com/answers/javascript/format-a-date/"
---

# How do you format a date in JavaScript?

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

```js
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.
