Flash cards
Review the key moves
What is the main idea behind JavaScript Temporal Conversion?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
Which statement best captures the main point of this lesson?
Complete the missing token from the example code.
___ legacyDate = new Date();Put the learning moves in the order that makes the concept easiest to apply.
Temporal Conversion Rules
The table below shows how Temporal types can be converted.
| From | Plain Date | Plain Time | Plain DateTime | Zoned DateTime | Instant |
|---|---|---|---|---|---|
| PlainDate | No | Yes | No | No | |
| PlainTime | No | No | No | No | |
| PlainDateTime | Yes | Yes | Yes | No | |
| ZonedDateTime | Yes | Yes | Yes | Yes | |
| Instant | No | No | No | Yes |
Conversion Methods
| 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();PlainDate to PlainDateTime
You might like to add a time.
Examples
const date = Temporal.PlainDate.from("2026-05-17");
const dateTime = date.toPlainDateTime();Combine Date and Time
You can combine PlainDate and PlainTime to create a PlainDateTime object.
Example
// Create a PlainDate object
const date = Temporal.PlainDate.from("2026-05-17");
// Create a PlainTime object
const time = Temporal.PlainTime.from("14:30");
// Convert into a PlainDateTime object
const dateTime = date.toPlainDateTime(time);PlainDateTime to PlainDate
Example
const dateTime = Temporal.PlainDateTime.from("2026-05-17T14:30");
const date = dateTime.toPlainDate();PlainDateTime to PlainTime
Example
const dateTime = Temporal.PlainDateTime.from("2026-05-17T14:30");
const time = dateTime.toPlainTime();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();ZonedDateTime to PlainDateTime
Example
const zoned = Temporal.ZonedDateTime.from("2026-05-17T14:30:00+02:00[Europe/Oslo]");
const dateTime = zoned.toPlainDateTime();ZonedDateTime to PlainDate
Example
const zoned = Temporal.ZonedDateTime.from("2026-05-17T14:30:00+02:00[Europe/Oslo]");
const date = zoned.toPlainDate();ZonedDateTime to PlainTime
Example
const zoned = Temporal.ZonedDateTime.from("2026-05-17T14:30:00+02:00[Europe/Oslo]");
const time = zoned.toPlainTime();ZonedDateTime to Instant
Example
const zoned = Temporal.ZonedDateTime.from("2026-05-17T14:30:00+02:00[Europe/Oslo]");
const instant = zoned.toInstant();Instant to ZonedDateTime
Instant does not have a toZonedDateTime() method.
You must convert it to a ISO zone first.
Wrong
const instant = Temporal.Instant.from("2026-05-17T12:30:00Z");
const zoned = instant.toZonedDateTime("Europe/Oslo");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 });PlainMonthDay to PlainDate
Example
const monthDay = new Temporal.PlainYearMonth(2026, 5);
const date = monthDay.toPlainDate({ year: 2026 });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');