Loading lesson path
Temporal.ZonedDateTime object represents a date and time with a time zone. It is the safest way to handle international date and time calculations. It prevents common DST bugs and makes time zone conversions clear and predictable.
How to use JavaScript Temporal.ZonedDateTime
How to avoid DST (Daylight Saving Time) bugs
Time zones and daylight saving time (DST) can cause serious bugs when using JavaScript Date. ZonedDateTime solves this by always storing the time zone together with the date and time. A Temporal.ZonedDateTime is a timezone and calendar-aware date/time object that represents a real time event from the perspective of a particular region on Earth. The Temporal.ZonedDateTime object is optimized for cases that require a time zone,
RFC 5545 calendar.
Example: December 7th, 1995 at 3:24 AM in US Pacific time (in Gregorian calendar).
const zonedDate = Temporal.ZonedDateTime.from({
timeZone: 'Europe/Oslo', year: 2026, month: 5, day: 17, hour: 14, minute: 30, second: 0, millisecond: 0, microsecond: 0, nanosecond: 500
});You can also create a ZonedDateTime from a string that includes a time zone.
const zdt = Temporal.ZonedDateTime.from
("2026-02-17T14:30:00[Europe/Oslo]");The time zone name is written inside square brackets. Get Current Date and Time with Time Zone
Temporal.Now.zonedDateTimeISO() method returns your system's current date, time, and time zone as a Temporal.ZonedDateTime object.
Get the current date and time from your system's time zone:
const now = Temporal.Now.zonedDateTimeISO();ISO 8601 format.
Formula
2026 - 03 - 02: The calendar date (Year - Month - Day).
T10:36:00: The time of day (T - Hour:Minute:Second).+01:00: The offset from UTC (Coordinated Universal Time).
Formula
[Europe/Oslo]: The IANA time zone name, which is the system's local time zone in this case.You can convert a ZonedDateTime to another time zone.
const oslo = Temporal.ZonedDateTime.from
("2026-05-17T14:30:00+01:00[Europe/Oslo]");
const newYork = oslo.withTimeZone("America/New_York");The exact moment stays the same, but the local clock time changes. Add Time Safely (DST Safe) Adding days across a daylight saving change can break with Date. ZonedDateTime handles this correctly.
const start = Temporal.ZonedDateTime.from
("2026-03-29T00:00:00+01:00[Europe/Oslo]");
const nextDay = start.add({ days: 1 });Temporal adjusts automatically if a DST change happens.
method calculates the duration between two temporal dates. Syntax t1.since( t2, options )
At time t1, how much time has passed since time t2 ?
Example: ZonedDateTime const start = Temporal.ZonedDateTime.from(
"2026-02-17T09:00:00+01:00[Europe/Oslo]");
const end = Temporal.ZonedDateTime.from(
"2026-02-17T17:30:00+01:00[Europe/Oslo]");
const duration = end.since(start);method returns a Temporal.Duration Object representing the elapsed time. The duration is positive if the "other" date is in the past. The duration is negative if the "other" date is in the future.
Formula
method creates a new zoned date - time with specified field(s) replaced.