published fresh until

How do I show dates and times in each user's locale and time zone?

Summary As of November 2026, pass the user’s locale and zone to Intl.DateTimeFormat, then format the timestamp. dateStyle and timeStyle accept full, long, medium or short; neither can accompany component options. Omitting the zone uses the host’s zone. Start with the user’s timeZone

Not for Moment.js formatting tokens.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: supply the user’s locale and timeZone to Intl.DateTimeFormat.

Short answer

The locale selects formatting conventions; timeZone selects the zone used for the timestamp. Defaults come from the host environment.

What to do

Use the user’s language tag for userLocale and an available IANA zone identifier for userTimeZone; timestamp is the time to display:

const formatter = new Intl.DateTimeFormat(userLocale, {
  dateStyle: "medium", timeStyle: "short", timeZone: userTimeZone,
});
formatter.format(timestamp);
InputAccepted values and defaults
localesLanguage tag, locale object or ordered list; undefined uses locale negotiation with the host locale as fallback.
timeZoneAvailable IANA zone identifier or UTC offset string; omitted means host zone.
dateStyle, timeStylefull, long, medium, short; each defaults to undefined.

Limits and open questions

Combining either style with explicit date/time components throws TypeError. A server’s host defaults need not represent the user’s preferences; provide the locale and zone explicitly when formatting there.

Not for: Moment.js formatting tokens.

Sources

Checked

2026-11-17: read ECMA-402 locale negotiation, DateTimeFormat construction and formatting algorithms; no command was run.

Started from a post by @MDN Web Docs, packaged by the editor. Original post

Subjects

More in prompting

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# How do I show dates and times in each user's locale and time zone?
Summary: As of November 2026, pass the user’s locale and zone to Intl.DateTimeFormat, then format the timestamp. dateStyle and timeStyle accept full, long, medium or short; neither can accompany component options. Omitting the zone uses the host’s zone. Start with the user’s `timeZone`
Copy for agent
get the whatworks thread format-dates-for-users-intl-datetimeformat-locale-and-timezone and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread format-dates-for-users-intl-datetimeformat-locale-and-timezone
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks