JavaScript Dates and Modern Time with Temporal
Understand the ECMAScript Date time-value model, parsing and UTC/local interpretation, mutation and serialization, then learn the modern Temporal types for exact instants, calendar values, time zones, and durations.
Advanced
Start with the model: an ECMAScript Date is a time value
The legacy Date API represents an instant as a Number of milliseconds from the ECMAScript epoch: 1970-01-01T00:00:00Z. A Date object does not itself carry an IANA time-zone identity. Local getters and formatters interpret the same time value through the host environment’s local time zone.
Output
Ready to run.
Quick check
What does new Date(0).getTime() represent?
Output
Ready to run.
Quick check
What does the trailing Z communicate here?
Output
Ready to run.
Quick check
What happens to the +02:00 offset when the Date is created?
Output
Ready to run.
Quick check
What does Date.UTC return?
Output
Ready to run.
Quick check
Which month is 8 in the Date multi-argument constructor?
Output
Ready to run.
Quick check
Why can getHours() and getUTCHours() differ?
Output
Ready to run.
Quick check
What does setUTCDate do to this Date object?
Output
Ready to run.
Quick check
What time value does an invalid Date contain?
Output
Ready to run.
Quick check
What is the safest lesson-level rule for Date.parse input?
Output
Ready to run.
Quick check
How is a Date normally serialized by JSON.stringify?
Output
Ready to run.
Quick check
What does Temporal.Instant primarily model?
Output
Ready to run.
Quick check
Which Temporal type is appropriate for a date without a time of day?
Output
Ready to run.
Quick check
What does Temporal.PlainTime deliberately omit?
Output
Ready to run.
Quick check
Why does ZonedDateTime carry an IANA time-zone identifier?
Output
Ready to run.
Quick check
What happens when a Temporal object is changed with an operation such as add()?
Output
Ready to run.
Quick check
What does Temporal.Duration represent?
Authoring rules for Date and Temporal
Use Date when you need compatibility with existing APIs or a millisecond-based instant model. Prefer explicit standardized date-time strings when parsing. Keep in mind that Date is mutable and does not preserve an IANA time-zone identity. For new code using Temporal, choose the type that matches the domain value: Instant for an exact instant, PlainDate/PlainTime/PlainDateTime for calendar or wall-clock values, ZonedDateTime when a named time zone matters, and Duration for amounts of time.
Temporal is now part of the modern ECMAScript track
Temporal reached Stage 4 in 2026 and is being integrated into ECMA-262/ECMA-402. Foxipa therefore teaches it as current modern ECMAScript, while still distinguishing it from the legacy Date API. Runtime availability can vary by the JavaScript engine/version used to run an example, so the runnable examples feature-detect Temporal rather than silently assuming it exists.
Thanks for your feedback.
Mark this learning resource complete to track your learning progress.