🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to JavaScript Notes
Topic #195

Temporal Conversion


Temporal Conversion Rules

The table below shows how Temporal types can be converted.

Col 1 Col 2 Col 3 Col 4 Col 5 Col 6
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

Col 1 Col 2 Col 3
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

Col 1 Col 2 Col 3 Col 4
From toPlainDate() toPlainDateTime() toZonedDateTime()
PlainYearMonth YES + day value No No
PlainMonthDay YES + year value No No

Note: 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');

Want to go beyond the notes?

Join CodingNow 2.0's JavaScript course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Temporal Conversion – FAQs

Quick answers about learning Temporal Conversion in JavaScript.

This free note from CodingNow 2.0 explains Temporal Conversion in JavaScript — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every JavaScript topic on CodingNow 2.0, including Temporal Conversion, is 100% free with no signup required.
With focused practice, most students grasp Temporal Conversion in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now