Marco Sieben

It's about time! The new Temporal API in JavaScript

The days of buggy, unpredictable date handling in JavaScript are over. Meet the new, immutable Temporal API and ditch your heavy libraries.

It's about time! The new Temporal API in JavaScript
#1about 10 minutes

The many problems with JavaScript's legacy Date object

The built-in Date object is flawed due to confusing constructors, mutability, and unreliable timezone and daylight saving time handling.

#2about 3 minutes

Defining the core use cases for time and dates

Applications require distinct representations for an exact point in time, a time within a specific timezone, and a plain date or time without timezone context.

#3about 2 minutes

Why popular date libraries are not a final solution

Libraries like Moment.js and Luxon introduce issues such as large bundle sizes, external dependency management, and do not solve all conceptual problems.

#4about 2 minutes

Introducing the new Temporal API and its core principles

The Temporal API is a modern, native solution for dates and times that is immutable, type-safe, ISO 8601 compliant, and uses a fail-fast approach.

#5about 5 minutes

Temporal API history, standardization, and browser support

Temporal has progressed through the TC39 process to become part of the ECMAScript standard and is now natively supported in major browsers and runtimes.

#6about 1 minute

Understanding the main data types in the Temporal API

Temporal provides specific objects for different needs, including Instant, ZonedDateTime, PlainDate, PlainTime, PlainDateTime, and Duration.

#7about 3 minutes

Creating and parsing Temporal objects from various sources

Use the `Temporal.now` object for the current time and the `.from()` factory methods to reliably parse ISO 8601 strings into the correct Temporal types.

#8about 8 minutes

How Temporal's fail-fast approach prevents common bugs

Unlike the legacy Date object, Temporal throws errors on ambiguous inputs, such as conflicting timezone and offset information, to ensure data integrity.

#9about 5 minutes

Formatting, manipulating, and comparing Temporal objects

Temporal objects are immutable and provide methods for formatting (`toLocaleString`), arithmetic (`add`, `subtract`), and comparison (`compare`, `equals`).

#10about 4 minutes

Navigating special cases and advanced calendar support

Learn about edge cases like adding variable-length units to an Instant and see how Temporal supports different calendar systems beyond the standard ISO calendar.

#11about 4 minutes

Comparing Temporal's performance and bundle size impact

Benchmarks show that the native Temporal API is significantly faster and results in a much smaller bundle size compared to popular libraries like Moment.js and Luxon.

#12about 4 minutes

A practical guide to migrating your project to Temporal

Migrate to Temporal incrementally by using polyfills for older browsers, carefully selecting the correct data types, and building temporary conversion bridges.

#13about 3 minutes

A real-world case study of migrating from Luxon

Migrating a medium-sized Angular application from Luxon to Temporal took about one week and uncovered a critical bug related to timezone interpretation.

#14about 2 minutes

Understanding Temporal's limitations and design choices

While powerful, Temporal is intentionally verbose, lacks convenience helpers like `endOfDay`, and does not parse non-ISO string formats by design.

Related jobs
Jobs that call for the skills explored in this talk.

Featured Partners

Related Articles

View all articles

From learning to earning

Jobs that call for the skills explored in this talk.