Skip to content
Foxipa

Suggest an edit

Tell us what should be corrected, clarified, or improved. Submission will be connected to Foxipa’s contribution service later.

No information is sent anywhere yet. Your suggestion is only prepared in your browser.

Learning

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.

Levels: Advanced ~55 min read

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.

Interactive Runnable example
Edit

Ready to run.

Quick check

What does new Date(0).getTime() represent?

Interactive Runnable example
Edit

Ready to run.

Quick check

What does the trailing Z communicate here?

Interactive Runnable example
Edit

Ready to run.

Quick check

What happens to the +02:00 offset when the Date is created?

Interactive Runnable example
Edit

Ready to run.

Quick check

What does Date.UTC return?

Interactive Runnable example
Edit

Ready to run.

Quick check

Which month is 8 in the Date multi-argument constructor?

Interactive Runnable example
Edit

Ready to run.

Quick check

Why can getHours() and getUTCHours() differ?

Interactive Runnable example
Edit

Ready to run.

Quick check

What does setUTCDate do to this Date object?

Interactive Runnable example
Edit

Ready to run.

Quick check

What time value does an invalid Date contain?

Interactive Runnable example
Edit

Ready to run.

Quick check

What is the safest lesson-level rule for Date.parse input?

Interactive Runnable example
Edit

Ready to run.

Quick check

How is a Date normally serialized by JSON.stringify?

Interactive Runnable example
Edit

Ready to run.

Quick check

What does Temporal.Instant primarily model?

Interactive Runnable example
Edit

Ready to run.

Quick check

Which Temporal type is appropriate for a date without a time of day?

Interactive Runnable example
Edit

Ready to run.

Quick check

What does Temporal.PlainTime deliberately omit?

Interactive Runnable example
Edit

Ready to run.

Quick check

Why does ZonedDateTime carry an IANA time-zone identifier?

Interactive Runnable example
Edit

Ready to run.

Quick check

What happens when a Temporal object is changed with an operation such as add()?

Interactive Runnable example
Edit

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.

Was this page helpful?

Mark this learning resource complete to track your learning progress.