PACKAGE · DATE & TIME

luxon

Immutable date wrapper

WEEKLY DOWNLOADS 15.1M
STARS 16.4K
FORKS 775
OPEN ISSUES 182
GZIP SIZE 22.3 kB
UNPACKED SIZE 4.6 MB
DEPENDENCIES 1
LAST UPDATED 9mo ago
DOWNLOAD TRENDS

luxon downloads — last 12 months

Download trends for luxon1 download series from Jun 2025 to May 2026. Use left and right arrow keys to inspect monthly values.031.4M62.8M94.3M125.7MJun 2025SepDecMarMay 2026
luxon
ABOUT LUXON

Luxon is an immutable date and time library designed to simplify date manipulation and formatting in JavaScript applications. It addresses the complexities and common pitfalls of the native JavaScript Date object by providing a more predictable and feature-rich API. By embracing immutability, Luxon ensures that date operations do not produce side effects, making it easier to reason about application state and prevent bugs.

This library is built with developers in mind, offering a clear and consistent interface for handling internationalization, time zones, and complex date calculations. Its design prioritizes developer experience and robustness, making it suitable for applications requiring reliable date and time management. The core philosophy revolves around providing a modern, intuitive, and safe way to work with dates, moving away from the mutability issues inherent in older JavaScript APIs.

Key API patterns in Luxon include its chainable methods for intuitive date construction and modification, such as `DateTime.now()`, `plus()`, `minus()`, and `set()`. The library provides distinct classes like `DateTime`, `Duration`, `Interval`, and `Zone` to represent different temporal concepts clearly. This object-oriented approach aids in structuring date-related logic effectively, while features like `toFormat()` and `toLocaleString()` enable sophisticated output customization.

Luxon integrates seamlessly into modern JavaScript workflows and frameworks. Its ES Module compatibility ensures efficient tree-shaking and bundle size optimization when used with bundlers like Webpack or Rollup. It is particularly well-suited for frontend frameworks like React, Vue, and Angular, as well as backend environments like Node.js, where consistent and predictable date handling is crucial.

With a gzipped bundle size of 22.3 kB, Luxon offers a balance between functionality and performance. While not the absolute smallest date library available, it provides a comprehensive feature set without imposing an excessive load on application bundles. The library's maturity, evidenced by its extensive use and active development, suggests a stable and reliable solution for many date-related challenges.

Developers should be aware that Luxon's immutability means that every operation returns a new instance, which can have performance implications if not managed carefully in highly performance-critical loops involving frequent date modifications. Furthermore, while comprehensive, its feature set might be more than necessary for applications with very basic date formatting or calculation requirements, where simpler alternatives might suffice.

WHEN TO USE
  • When performing complex date arithmetic, such as calculating workdays, adding business hours, or determining the difference between two dates with specific units.
  • When consistently formatting dates and times across different locales and required formats using `toFormat()` and `toLocaleString()`.
  • When managing and displaying dates and times across various time zones, leveraging the `Zone` class for accurate conversions and representations.
  • When ensuring date operations do not mutate existing date objects, adhering to immutable patterns for predictable state management.
  • When integrating with internationalization (i18n) libraries that require standardized date and time output for global users.
  • When building applications that require robust handling of durations and intervals, utilizing `Duration` and `Interval` objects for precise temporal measurements.
WHEN NOT TO USE
  • If your application only requires very basic date parsing and string formatting where native `Date` object methods are sufficient.
  • If minimizing bundle size is the absolute highest priority and only minimal date manipulation is needed, consider a lighter-weight utility.
  • When performing extremely high-frequency date modifications within tight loops where the overhead of creating new immutable instances could become a bottleneck.
  • If all date handling can be managed by a backend service and the frontend requires only static display without interactive manipulation.
  • When using a framework or environment that provides its own opinionated and highly optimized date handling utilities that meet all other code adheres to.

CORRECTIONS

Spot wrong data here?

A short note helps us fix it.

Anonymous · No account · No email back

COMPARISONS 5
luxon vs date-fns ★ 36.6K · 43.7M/wk luxon vs moment ★ 48.0K · 16.3M/wk luxon vs dayjs ★ 48.7K · 26.4M/wk luxon vs @formkit/tempo ★ 2.6K · 47.5K/wk luxon vs @js-joda/core ★ 1.7K · 1.7M/wk