# Temporal in Node.js 26: Replacing Date Without a Library

> Node.js 26 enables the Temporal API by default. See how Instant, ZonedDateTime and PlainDate fix Date bugs, with DST-safe examples and a migration plan.

Node.js 26 enables the Temporal API by default. After years of `Date` quirks and date libraries added to every project, a built-in replacement is available on the Node.js 26 line, which the [Node.js releases page](https://nodejs.org/en/about/previous-releases) lists as LTS as of this writing.

This article covers what Temporal is, the three types that handle most backend work, the bugs it removes, and how to adopt it without rewriting your codebase. The examples were run against the `@js-temporal/polyfill` package, not against a Node.js 26 binary, so confirm the output on your own runtime.


## Why Date keeps causing bugs

`Date` is one type doing several jobs. It stores a moment in time, but it is often used as a calendar date ("the invoice is due on the 5th") or a wall-clock time. It only knows two zones, UTC and the machine's local zone. It is mutable, months count from zero, and parsing strings that aren't ISO 8601 depends on the engine.

Backend code hits these limits quickly:

- A server in UTC cannot reliably answer "what day is it for this customer in Jakarta?" without a library.
- Adding "one day" by adding 86,400,000 ms is wrong across a daylight saving change.
- A date-only value like a birthday is stored as midnight UTC, then shifts to the previous day when formatted in a western time zone.

Libraries such as date-fns, Luxon and Day.js worked around this. Temporal moves the same ideas into the language.

## What changed in Node.js 26

Per the [Node.js 26.0.0 release notes](https://nodejs.org/en/blog/release/v26.0.0), "the Temporal API is now enabled by default in Node.js 26." The release moved to V8 14.6 and Undici 8, and removed some legacy APIs, so read the full notes before upgrading. The same release notes list build commits that add Rust toolchain checks for Temporal, which matters only if you compile Node.js from source.

Two caveats apply for browser-facing code. Temporal is a global, not an import, and its support in other runtimes and browsers varies, so check current compatibility data before using it in client bundles. For code that must run in older runtimes, a polyfill such as `@js-temporal/polyfill` follows the same API.

## The types that matter

Temporal has more types than `Date`, and that is the point: each one says what the value means.

| Type | Meaning | Use it for |
|---|---|---|
| `Temporal.Instant` | An exact moment, no zone | Timestamps, logs, event ordering |
| `Temporal.ZonedDateTime` | An instant plus a time zone | Appointments, schedules, anything shown to a user |
| `Temporal.PlainDate` | A calendar date, no time or zone | Birthdays, due dates, billing days |
| `Temporal.PlainDateTime` / `PlainTime` | Wall-clock values with no zone | Store opening hours, recurring local times |
| `Temporal.Duration` | A length of time | Intervals, timeouts, SLAs |

All Temporal objects are immutable. Methods like `add` return a new object.

## Examples

### Store instants, display zoned values

Persist `Instant` values and convert only for display:

```ts
const created = Temporal.Instant.from('2026-11-05T12:00:00Z');

console.log(created.epochMilliseconds); // 1793880000000
console.log(created.toZonedDateTimeISO('Asia/Jakarta').toString());
// 2026-11-05T19:00:00+07:00[Asia/Jakarta]
```

`epochMilliseconds` is a plain number, so it works with databases and APIs that store epoch times.

### Add days safely across DST

In `America/New_York`, clocks moved forward on 8 March 2026. Adding one calendar day and adding 24 hours give different answers:

```ts
const start = Temporal.ZonedDateTime.from('2026-03-07T09:00:00[America/New_York]');

start.add({ days: 1 }).toString();
// 2026-03-08T09:00:00-04:00[America/New_York]  (same wall-clock time)

start.add({ hours: 24 }).toString();
// 2026-03-08T10:00:00-04:00[America/New_York]  (exactly 24 hours later)
```

Use `days` for "same time tomorrow" and `hours` for elapsed time. With `Date`, both are the same arithmetic, so one of them is silently wrong.

### Handle skipped and repeated times

Local times that don't exist, or occur twice, are explicit decisions:

```ts
// 02:30 on 2026-03-08 does not exist in New York. Default: moved forward.
Temporal.ZonedDateTime.from('2026-03-08T02:30:00[America/New_York]').toString();
// 2026-03-08T03:30:00-04:00[America/New_York]

// Fail instead of guessing:
Temporal.ZonedDateTime.from('2026-03-08T02:30:00[America/New_York]', {
  disambiguation: 'reject',
}); // throws RangeError

// 01:30 on 2026-11-01 occurs twice. Default is the earlier one:
Temporal.ZonedDateTime.from('2026-11-01T01:30:00[America/New_York]').toString();
// 2026-11-01T01:30:00-04:00[America/New_York]

Temporal.ZonedDateTime.from('2026-11-01T01:30:00[America/New_York]', {
  disambiguation: 'later',
}).toString();
// 2026-11-01T01:30:00-05:00[America/New_York]
```

For scheduling features, use `reject` and ask the user, rather than shifting a booking silently.

### Date-only values and month-end arithmetic

```ts
const due = Temporal.PlainDate.from('2026-01-31');
due.add({ months: 1 }).toString(); // 2026-02-28

const a = Temporal.PlainDate.from('2026-11-05');
const b = Temporal.PlainDate.from('2027-02-28');
a.until(b, { largestUnit: 'month' }).toString(); // P3M23D

Temporal.PlainDate.from('2026-02-31', { overflow: 'reject' }); // throws RangeError
```

By default, invalid days are clamped (`overflow: 'constrain'`). Use `reject` when validating user input. A `PlainDate` has no time zone, so it cannot shift to the previous day.

### Durations and comparison

```ts
const d = Temporal.Duration.from({ hours: 26, minutes: 40 });
d.round({ largestUnit: 'day', smallestUnit: 'hour', roundingMode: 'halfExpand' }).toString();
// P1DT3H

Temporal.Duration.from('PT90M').total({ unit: 'hour' }); // 1.5

const t = Temporal.Instant.from('2026-11-05T12:00:00Z');
Temporal.Instant.compare(t, t.add({ seconds: 1 })); // -1

t.until(Temporal.Instant.from('2026-11-05T15:30:00Z'), { largestUnit: 'hour' }).toString();
// PT3H30M
```

Two details trip people up. Instants measure exact time, so `largestUnit: 'month'` throws for them because months have no fixed length; use a `ZonedDateTime` or `PlainDate` for calendar units. And `==` compares object identity, so use `equals()` or `compare()`:

```ts
a.equals(Temporal.PlainDate.from('2026-11-05')); // true
a == Temporal.PlainDate.from('2026-11-05');      // false
```

### Serialising to JSON

Temporal objects serialise to ISO strings, so they round-trip through JSON and APIs:

```ts
JSON.stringify({ at: t, day: a });
// {"at":"2026-11-05T12:00:00Z","day":"2026-11-05"}
```

Parse them back with `Temporal.Instant.from()` or `Temporal.PlainDate.from()`. Validate at the boundary, for example with a schema library, and treat a `RangeError` as bad input, not a server fault.

## Migrating from Date

You do not need a big-bang rewrite. A workable order:

1. **Pick semantics, not syntax.** For each `Date` in your code, decide whether it is an instant, a zoned time or a calendar date. This is where most latent bugs surface.
2. **Convert at the edges.** Bridge with epoch milliseconds, which both APIs support: `Temporal.Instant.fromEpochMilliseconds(date.getTime())` and `new Date(instant.epochMilliseconds)`. The proposal also defines `Date.prototype.toTemporalInstant()`, but it was `undefined` in the polyfill I tested, so don't depend on it without checking your runtime.
3. **Start with new code and the worst offenders.** Billing cycles, scheduling, reports by local day and anything near DST.
4. **Type your boundaries.** In TypeScript, use `Temporal.Instant` or `Temporal.PlainDate` in function signatures, not `Date` or `string`. Check that your TypeScript version's `lib` includes Temporal types, or use the polyfill's types.
5. **Delete the date library last,** once nothing imports it.

## Advantages and limitations

**Advantages**

- Types that encode meaning, so mistakes become type errors.
- Real time zone support and explicit DST handling.
- Immutable objects, no accidental mutation.
- Nanosecond precision and ISO 8601 round-tripping.
- No dependency and no bundle cost on the server.

**Limitations**

- Larger API surface to learn than `Date`.
- Runtime support varies outside Node.js 26, so shared code may need a polyfill.
- Third-party libraries, ORMs and validators that expect `Date` need conversion at the boundary.
- Formatting and calendar behaviour depend on the runtime's ICU data. Test locale-specific output in your target environment.

## Best practices

- Store instants (or UTC epoch values) and the IANA time zone ID separately when you need to recreate local times.
- Store a `PlainDate` as an ISO string for date-only values.
- Keep user-facing zone logic in `ZonedDateTime`, not manual offset maths.
- Choose `disambiguation` and `overflow` options deliberately for user input.
- Compare with `compare()` or `equals()`, never `==`.
- Pin your Node.js version in `engines` and CI so Temporal availability is guaranteed.

## Common mistakes

- Using `Instant` for "the 5th of every month". That is a calendar rule, so use `PlainDate`.
- Adding `hours: 24` when you mean "tomorrow".
- Expecting `Instant.until` to return months.
- Storing the UTC offset (`+07:00`) instead of the zone ID, which breaks after a DST or rule change.
- Assuming the server's zone matches the user's. Pass the zone explicitly.

Runtime features land differently in each framework, and [the Node.js release schedule](/blog/nodejs-release-schedule-one-lts-per-year/) explains which version you should actually be on. I use this under [Node.js and TypeScript development](/services/nodejs-typescript-development/). The API is documented in [Temporal's proposal](https://tc39.es/proposal-temporal/docs/). If you are replacing a date library, [tell me which one](/contact/).

## Frequently asked questions

### Is Temporal available in Node.js 26 without a flag?

Yes. The Node.js 26.0.0 release notes state it is enabled by default. Earlier versions need a polyfill.

### Does Temporal replace date-fns or Luxon?

For parsing, arithmetic, comparison and time zones, mostly yes. Formatting helpers and domain-specific utilities (business days, relative time strings) may still come from a library.

### Can I use Temporal with TypeScript?

Yes, provided your TypeScript version ships Temporal types in its `lib` files or you use the polyfill's types. Check your compiler's release notes, as typings have lagged runtime support.

### Should I use Temporal in browser code?

Only after checking current browser support for your audience, or by shipping a polyfill.

### How do I get the current time?

`Temporal.Now.instant()` for an instant, `Temporal.Now.zonedDateTimeISO('Asia/Jakarta')` for a zoned value, and `Temporal.Now.plainDateISO()` for today's date in the system zone.

## Conclusion

Temporal is worth adopting because it removes a dependency, not because it is in the runtime. If you already use a date library you trust, the reason to move is the type safety and the smaller bundle, and that is a decision to make deliberately.

## References and further reading

- [Node.js 26.0.0 release notes](https://nodejs.org/en/blog/release/v26.0.0), the source for Temporal being enabled by default.
- [Node.js previous releases](https://nodejs.org/en/about/previous-releases), for the LTS status of each line.
- [Temporal documentation](https://tc39.es/proposal-temporal/docs/), the reference for the full API.
- [@js-temporal/polyfill](https://www.npmjs.com/package/@js-temporal/polyfill), used to check the examples above.

If you're planning a Node.js upgrade or auditing date handling in a billing or scheduling system, see my [Node.js and TypeScript development](/services/nodejs-typescript-development/) services, or [tell me about your project](/contact/).

---

HTML version: https://fullstackweb.dev/blog/temporal-api-nodejs-26/
Maintained by Hendra Nicholas, Senior Full-Stack Software Engineer & AI Engineer, hello@fullstackweb.dev.
