toTimeZone
Projects a Date into a target IANA time zone. It returns a wall-clock carrier Date whose local getters (getHours(), getDate(), ...) show the target zone's wall clock in the runtime's local zone. The returned epoch is not the original instant - it is a carrier value for display. Pro-only; re-exported from @svar-ui/svelte-calendar.
Usage
function toTimeZone(date: Date, timeZone: string): Date;
date- the instant to project.timeZone- an IANA zone id (for example"America/New_York"). Invalid or unsupported ids throw from the platform.
Pair it with fromTimeZone to interpret a carrier's fields back into a real instant.
Example
import { toTimeZone } from "@svar-ui/svelte-calendar";
const instant = new Date("2026-05-05T12:00:00Z");
const projected = toTimeZone(instant, "America/New_York");
projected.getHours(); // 8 — the New York wall-clock hour
Related articles
- Time zones — projecting events and switching the displayed zone.
fromTimeZone— inverse: read a carrier's wall time back to an instant.