Guide
date-fns-tz vs Luxon vs Spacetime 2026



Compare date-fns-tz, Luxon, and Spacetime for JavaScript timezone conversion, formatting, daylight saving time, and Moment-Timezone migration.
Contents
Contents
TL;DR
Use date-fns-tz to add timezone conversion and formatting to an existing date-fns codebase. Use Luxon when you want immutable date/time objects, durations, intervals, and a way to inspect both offsets for an ambiguous local time. Use Spacetime when you need bundled timezone rules and have verified the dates and zones your app handles. Its maintainers document that a single set of DST rules is reused for past and future dates, which can produce wrong offsets. Spacetime’s timezone limitations
Key Takeaways
- date-fns-tz uses native
Datevalues and gets timezone rules from the runtime. - Luxon uses
Intlfor timezone rules and provides separate types for dates, durations, and intervals. - Spacetime ships its own timezone rules.
Quick Comparison
| Check | date-fns-tz | Luxon | Spacetime |
|---|---|---|---|
| Keep existing date-fns calls | Add helpers for zone-aware conversion and formatting | Migrate to DateTime where needed | Migrate to Spacetime objects where needed |
| Get timezone rules | Runtime Intl | Runtime Intl | Bundled rules |
| Inspect an ambiguous local time | Require an explicit offset in the input | Compare candidates with getPossibleOffsets() | Require an explicit offset in the input |
date-fns-tz
date-fns-tz — timezone support for date-fns:
Convert between timezones
import { formatInTimeZone, fromZonedTime } from "date-fns-tz"
const utcDate = new Date("2026-03-09T12:00:00Z")
// Format in a specific timezone:
console.log(formatInTimeZone(utcDate, "America/New_York", "yyyy-MM-dd HH:mm:ss xxx"))
// → "2026-03-09 08:00:00 -04:00"
console.log(formatInTimeZone(utcDate, "Asia/Tokyo", "yyyy-MM-dd HH:mm:ss xxx"))
// → "2026-03-09 21:00:00 +09:00"
console.log(formatInTimeZone(utcDate, "Europe/London", "yyyy-MM-dd HH:mm:ss xxx"))
// → "2026-03-09 12:00:00 +00:00"
// Interpret a New York wall-clock time for storage:
const backToUtc = fromZonedTime("2026-03-09T08:00:00", "America/New_York")
console.log(backToUtc.toISOString())
// → "2026-03-09T12:00:00.000Z"
Luxon
Luxon — modern date/time library:
Timezone support
import { DateTime } from "luxon"
// Create in a timezone:
const ny = DateTime.fromISO("2026-03-09T12:00:00Z", { zone: "America/New_York" })
console.log(ny.toFormat("yyyy-MM-dd HH:mm:ss ZZ"))
// → "2026-03-09 08:00:00 -04:00"
// Create from specific timezone:
const tokyo = DateTime.fromObject(
{ year: 2026, month: 3, day: 9, hour: 21 },
{ zone: "Asia/Tokyo" }
)
console.log(tokyo.toISO())
// → "2026-03-09T21:00:00.000+09:00"
// Convert between timezones:
const londonTime = tokyo.setZone("Europe/London")
console.log(londonTime.toFormat("HH:mm ZZ"))
// → "12:00 +00:00"
// UTC:
const utc = DateTime.utc(2026, 3, 9, 12, 0)
console.log(utc.setZone("America/Chicago").toFormat("h:mm a ZZ"))
// → "7:00 AM -05:00"
DST handling
import { DateTime } from "luxon"
// Luxon handles DST transitions automatically:
const beforeDST = DateTime.fromObject(
{ year: 2026, month: 3, day: 8, hour: 1, minute: 30 },
{ zone: "America/New_York" }
)
console.log(beforeDST.toFormat("h:mm a ZZZZ")) // → "1:30 AM EST"
const afterDST = beforeDST.plus({ hours: 1 })
console.log(afterDST.toFormat("h:mm a ZZZZ")) // → "3:30 AM EDT"
// (skips 2:00 AM — spring forward)
// Check if in DST:
console.log(afterDST.isInDST) // → true
Spacetime
Spacetime — lightweight timezone library:
Install the version used in these examples with npm install --save-exact spacetime@7.19.0.
Timezone conversion and DST
import spacetime from "spacetime"
const london = spacetime("2026-03-09", "Europe/London")
console.log(london.format("iso"))
// → "2026-03-09T00:00:00.000Z"
const meeting = spacetime("2026-03-09 3:00pm", "America/New_York")
console.log(meeting.format("iso"))
// → "2026-03-09T15:00:00.000-05:00"
console.log(meeting.goto("Europe/London").format("time"))
// → "8:00pm"
console.log(meeting.goto("Asia/Tokyo").format("time"))
// → "5:00am" (March 10)
const before = spacetime("2026-03-08", "America/New_York")
const after = before.add(1, "day")
console.log(before.isDST(), before.offset())
// → false -300
console.log(after.isDST(), after.offset())
// → false -300
These are Spacetime 7.19.0’s outputs. For the March 9 meeting, Luxon uses New York’s -04:00 offset and resolves the meeting to 19:00Z, one hour earlier. Compare expected offsets around transitions before using Spacetime for scheduling.
Feature Comparison
| Feature | date-fns-tz | Luxon | Spacetime |
|---|---|---|---|
| Date model | Native Date | Immutable DateTime | Spacetime object, mostly immutable |
| Timezone rules | Runtime Intl | Runtime Intl | Bundled |
| Change the display timezone | formatInTimeZone() | setZone() | goto() |
Bundle Size & Browser Compatibility
Measure the imports used in your own production bundle. Run the same timezone cases on the browsers and server runtimes you support. For Spacetime, test the bundled rules again when you upgrade the package.
DST Edge Cases and Why They Matter
When clocks fall back, a local time can refer to more than one instant. When clocks spring forward, some local times disappear. Keep the offset or UTC instant when the input includes it. If a user enters an ambiguous local time, ask which offset they mean before saving it.
import { DateTime } from "luxon"
const local = DateTime.fromISO("2025-11-02T01:30:00", {
zone: "America/New_York",
})
const candidates = local.getPossibleOffsets().map((time) => time.toISO())
console.log(candidates)
// → ["2025-11-02T01:30:00.000-04:00", "2025-11-02T01:30:00.000-05:00"]
For a spring-forward input, compare the parsed wall-clock fields with what the user entered. A parser may move a nonexistent time forward. See Luxon’s timezone documentation.
When to Use Each
Use date-fns-tz if:
- Already using date-fns for date operations
- Want tree-shakeable timezone functions
- Prefer working with native Date objects
- Need only timezone conversion and formatting
Use Luxon if:
- Need a comprehensive date/time library with timezones
- Want Duration, Interval, and timezone support built-in
- Migrating from Moment.js (same team, spiritual successor)
- Need the richest API for date/time operations
Use Spacetime if:
- Want the most human-friendly timezone API
- Need a lightweight library focused on timezones
- Have checked offsets for the timezones and dates your app needs
- Prefer natural language methods (dayName, monthName)
Migration Guide
From Moment-Timezone to Luxon
Moment changes the original object when you call add(). Luxon’s plus() returns a new object. Use fromISO() for ISO input or fromFormat() when the input follows a custom pattern. Check format tokens separately. For example, Moment uses Z for an offset with a colon, while Luxon uses ZZ.
import moment from "moment-timezone"
import { DateTime } from "luxon"
const zone = "America/New_York"
const input = "2026-03-09T15:00:00"
const original = moment.tz(input, zone)
const originalLabel = original.format("HH:mm Z") // 15:00 -04:00
original.add(1, "hour") // original now holds 16:00
const dateTime = DateTime.fromISO(input, { zone })
const label = dateTime.toFormat("HH:mm ZZ") // 15:00 -04:00
const later = dateTime.plus({ hours: 1 }) // later holds 16:00
console.log(originalLabel, label) // 15:00 -04:00 15:00 -04:00
console.log(original.format("HH:mm"), dateTime.toFormat("HH:mm"), later.toFormat("HH:mm"))
// → 16:00 15:00 16:00
The Luxon migration guide covers common operations. Make a list of the Moment calls your app uses and test parsing, formatting, and arithmetic separately before replacing them.
From date-fns to date-fns-tz
Keep your date-fns calls for ordinary date arithmetic. Use formatInTimeZone() to display an existing instant in a named zone and fromZonedTime() to convert a wall-clock time to a UTC instant.
// date-fns (no timezone)
import { format, parseISO } from "date-fns"
console.log(format(parseISO("2026-03-09T15:00:00Z"), "h:mm a"))
// Output depends on the host timezone.
// date-fns-tz (timezone-aware)
import { formatInTimeZone } from "date-fns-tz"
console.log(formatInTimeZone(new Date("2026-03-09T15:00:00Z"), "America/New_York", "h:mm a"))
// → "11:00 AM" (consistent regardless of server timezone)
Source notes
Methodology
The code examples were run with Node.js 26.13.0, Luxon 3.7.2, Moment-Timezone 0.6.6, date-fns-tz 3.2.0, date-fns 4.1.0, and Spacetime 7.19.0. The fixture ran under UTC, America/Los_Angeles, and Asia/Tokyo host timezones.
Timezone Database Updates and IANA Maintenance
Check recent or upcoming timezone rule changes on the exact runtimes you deploy. date-fns-tz and Luxon take their rules from the runtime, so apply the relevant runtime or timezone-data updates. Spacetime bundles rules with the package, so check for a package release that includes the rule you need.
Server vs Client Timezone Handling
Use the same timestamp label for server rendering and the first client render. In Next.js, a Client Component can also render on the server. Pass a label formatted in UTC or in the user’s stored timezone. If you need the browser’s local timezone, show that shared label first and switch to browser-local formatting in useEffect after hydration. Next.js hydration guide
For global applications serving users across many timezones, the recommended architecture is: store all timestamps as UTC in the database, transmit them as ISO 8601 strings with explicit Z or +00:00 suffix in your API, and convert to the user's local timezone only at the display layer. This is the single most reliable approach to avoiding timezone-related bugs in production, and it is compatible with all three libraries covered here.
Compare date/time libraries and developer tooling on PkgPulse →
See also: date-fns vs Luxon and date-fns vs Moment.js, acorn vs @babel/parser vs espree.