JavaScript Temporal Convertion
Temporal Conversion Rules
The table below shows how Temporal types can be converted.
| From / To | Plain Date |
Plain Time |
Plain DateTime |
Zoned DateTime |
Instant |
| PlainDate | Same | - | Yes | - | - |
| PlainTime | - | Same | - | - | - |
| PlainDateTime | Yes | Yes | Same | Yes | - |
| ZonedDateTime | Yes | Yes | Yes | Same | Yes |
| Instant | - | - | - | Yes | Same |
| Duration | - | - | - | - | - |
Duration represents an amount of time, not a date or time value.
Methods to Use
| From | To | Method |
|---|---|---|
| Date | Instant | date.toTemporalInstant() |
| PlainDate | PlainTime | None |
| PlainDate | PlainDateTime | date.toPlainDateTime() |
| PlainDate | ZonedTime | None |
| PlainDate | Instant | None |
| PlainYearMonth | PlainDate | yearmonth.toPlainDate() |
| PlainMonthDay | PlainDate | monthday.toPlainDate() |
| PlainDateTime | PlainDate | datetime.toPlainDate() |
| PlainDateTime | PlainTime | datetime.toPlainTime() |
| PlainDateTime | ZonedDateTime | datetime.toZonedDateTime() |
| PlainDateTime | Instant | None |
| ZonedDateTime | PlainDate | zoned.toPlainDate() |
| ZonedDateTime | PlainDateTime | zoned.toPlainDateTime() |
| ZonedDateTime | PlainTime | zoned.toPlainTime() |
| ZonedDateTime | Instant | zoned.toInstant() |
| Instant | ZonedDateTime | zoned.toZonedDateTimeISO() |
Legacy Date to Temporal Instant
Example
const legacyDate = new Date();
const instant = legacyDate.toTemporalInstant();
Try it Yourself »
PlainDate to PlainDateTime
You might like to add a time.
Examples
const date = Temporal.PlainDate.from("2026-05-17");
const dateTime = date.toPlainDateTime();
Try it Yourself »
const date = Temporal.PlainDate.from("2026-05-17");
const dateTime = date.toPlainDateTime("14:30");
Try it Yourself »
PlainDateTime to PlainDate
Example
const dateTime = Temporal.PlainDateTime.from("2026-05-17T14:30");
const date = dateTime.toPlainDate();
Try it Yourself »
PlainDateTime to PlainTime
Example
const dateTime = Temporal.PlainDateTime.from("2026-05-17T14:30");
const time = dateTime.toPlainTime();
Try it Yourself »
PlainDateTime to ZonedDateTime
PlainDateTime does not contain a time zone.
You must provide one to create a ZonedDateTime.
Wrong
const dateTime = Temporal.PlainDateTime.from("2026-05-17T14:30");
const zoned = dateTime.toZonedDateTime();
Correct
const dateTime = Temporal.PlainDateTime.from("2026-05-17T14:30");
const zoned = dateTime.toZonedDateTime("Europe/Oslo");
Try it Yourself »
ZonedDateTime to PlainDateTime
Example
const zoned = Temporal.ZonedDateTime.from("2026-05-17T14:30:00+02:00[Europe/Oslo]");
const dateTime = zoned.toPlainDateTime();
Try it Yourself »
ZonedDateTime to PlainDate
Example
const zoned = Temporal.ZonedDateTime.from("2026-05-17T14:30:00+02:00[Europe/Oslo]");
const date = zoned.toPlainDate();
Try it Yourself »
ZonedDateTime to PlainTime
Example
const zoned = Temporal.ZonedDateTime.from("2026-05-17T14:30:00+02:00[Europe/Oslo]");
const time = zoned.toPlainTime();
Try it Yourself »
ZonedDateTime to Instant
Example
const zoned = Temporal.ZonedDateTime.from("2026-05-17T14:30:00+02:00[Europe/Oslo]");
const instant = zoned.toInstant();
Try it Yourself »
Instant to ZonedDateTime
Instant does not have a toZonedDateTime() method.
You must convert it to a ISO zone first.
Wring
const instant = Temporal.Instant.from("2026-05-17T12:30:00Z");
const zoned = instant.toZonedDateTime("Europe/Oslo");
Try it Yourself »
Correct
const instant = Temporal.Instant.from("2026-05-17T12:30:00Z");
const zoned = instant.toZonedDateTimeISO("Europe/Oslo");
Try it Yourself »
Special Temporal Types
| From | toPlainDate() | toPlainDateTime() | toZonedDateTime() |
|---|---|---|---|
| PlainYearMonth | YES + day value |
No | No |
| PlainMonthDay | YES + year value |
No | No |
PlainMonthDay and PlainYearMonth need missing parts before becoming a full date.
PlainYearMonth to PlainDate
Example
const yearMonth = new Temporal.PlainYearMonth(2026, 5);
const date = yearMonth.toPlainDate({ day: 17 });
Try it Yourself »
PlainMonthDay to PlainDate
Example
const monthDay = new Temporal.PlainYearMonth(2026, 5);
const date = monthDay.toPlainDate({ year: 2026 });
Try it Yourself »
Time Zone Conversion
Converting time from another time zone is handled by the ZonedDateTime method withTimeZone().
Example
const zdtOslo = Temporal.Now.zonedDateTimeISO('Europe/Oslo');
const zdtTokyo = zdtOslo.withTimeZone('Asia/Tokyo');
Try it Yourself »