Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/content/changelog/workers/2026-12-01-temporal-api.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: The Temporal API is now available in Workers
description: Workers now support Temporal, the modern JavaScript API for dates, times, and time zones.
products:
- workers
date: 2026-12-01
---

import { TypeScriptExample, WranglerConfig } from "~/components";

Workers now support the [Temporal API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal), the modern JavaScript standard for dates and times. You can convert between time zones, do calendar-correct date arithmetic, and work with plain dates and times, without bundling a date library such as Moment.js, Luxon, or date-fns.

Temporal will be turned on for Workers with a [compatibility date](/workers/configuration/compatibility-dates/) of `2026-12-01` or later. To use it with an earlier compatibility date, add the [`temporal`](/workers/configuration/compatibility-flags/#enable-the-temporal-api) compatibility flag:

<WranglerConfig>

```toml
compatibility_flags = ["temporal"]
```

</WranglerConfig>

This example shows the time a meeting starts in the visitor's time zone, using the time zone Cloudflare detects for the request:

<TypeScriptExample filename="src/index.ts">

```ts
export default {
async fetch(request): Promise<Response> {
const timeZone = request.cf?.timezone ?? "UTC";

const meeting = Temporal.ZonedDateTime.from(
"2026-12-15T09:30[America/New_York]",
);
const local = meeting.withTimeZone(timeZone);

return new Response(
`The meeting starts at ${local.toPlainTime()} on ${local.toPlainDate()} (${timeZone}).`,
);
},
} satisfies ExportedHandler;
```

</TypeScriptExample>

For the full API, refer to the [Temporal documentation on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal).
37 changes: 37 additions & 0 deletions src/content/compatibility-flags/temporal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
_build:
publishResources: false
render: never
list: never

name: "Enable the Temporal API"
sort_date: "2026-12-01"
enable_date: "2026-12-01"
enable_flag: "temporal"
disable_flag: "no_temporal"
---

Makes the [Temporal API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal) available in your Worker. Temporal is the modern JavaScript standard for working with dates and times, and replaces many of the uses of `Date` and of date libraries such as Moment.js, Luxon, or date-fns.

With Temporal you can:

- Convert between time zones, with daylight saving time handled for you.
- Work with plain dates and times, such as a birthday or an opening hour, without a time zone getting in the way.
- Add and subtract durations like "1 month and 3 days" and get calendar-correct results.
- Compare and sort dates and times, and format them for any locale.

Temporal objects are immutable, so a value never changes after you create it.

```js
const meeting = Temporal.ZonedDateTime.from(
"2026-12-15T09:30[America/New_York]",
);

meeting.withTimeZone("Europe/London").toString();
// "2026-12-15T14:30:00+00:00[Europe/London]"

meeting.add({ months: 1 }).toPlainDate().toString();
// "2027-01-15"
```

`Temporal.Now` returns the same time as `Date.now()`. For more information, refer to [Performance and timers](/workers/runtime-apis/performance/).
Loading