Format Date in Time Zone (YYYY-MM-DD)

intermediate
By FrontendAtlas Editorial · Updated Oct 10, 2026
Implement formatDateInTimeZone(date, timeZone) to return a YYYY-MM-DD string for a given Date (or timestamp) in a specific IANA time zone. Use Intl.DateTimeFormat and handle invalid dates safely.

Arguments

  • date: Date | number — Date object or timestamp (ms).
  • timeZone: string — IANA time zone (e.g., 'UTC', 'America/Los_Angeles').

Returns

string — Formatted date as YYYY-MM-DD in the specified time zone.

Solution idea

Use Intl.DateTimeFormat with a fixed locale and the provided timeZone. formatToParts lets you build a stable YYYY-MM-DD string without relying on locale-specific formatting.

Examples
formatDateInTimeZone(new Date('2020-01-01T00:30:00Z'), 'America/Los_Angeles') // => '2019-12-31'

formatDateInTimeZone(1593646200000, 'UTC') // => '2020-07-01'