PACKAGE · DATE & TIME

dayjs

2KB immutable date time library alternative to Moment.js with the same modern API

WEEKLY DOWNLOADS 26.4M
STARS 48.7K
FORKS 2.4K
OPEN ISSUES 1.3K
GZIP SIZE 3.5 kB
UNPACKED SIZE 680.1 kB
DEPENDENCIES 1
LAST UPDATED 7mo ago
DOWNLOAD TRENDS

dayjs downloads — last 12 months

Download trends for dayjs1 download series from Jun 2025 to May 2026. Use left and right arrow keys to inspect monthly values.052.9M105.7M158.6M211.5MJun 2025SepDecMarMay 2026
dayjs
ABOUT DAYJS

Day.js is a lightweight JavaScript library designed for immutable date and time manipulation. It addresses the common need for a modern, efficient, and straightforward way to handle dates and times in web applications, offering an alternative to more verbose libraries. Its primary goal is to provide a familiar API for developers accustomed to other date libraries, while significantly reducing bundle size.

The library's core philosophy centers around immutability and a minimal API surface. This means that once a Day.js object is created, it cannot be altered; all operations return new instances, preventing unintended side effects in your application state. This design makes it particularly suitable for developers building applications with predictable state management or functional programming paradigms.

Day.js boasts a fluent API that mirrors common date operations, such as parsing, formatting, and manipulating dates. Key methods include `dayjs()`, which is used for parsing dates, `format()`, for displaying dates in various string formats according to tokens, and manipulation methods like `add()`, `subtract()`, and `set()`. Its plugin system allows for extending functionality, such as timezone support or local time handling, without bloating the core library.

The package integrates seamlessly into most JavaScript environments and build tools, including modern frontend frameworks like React, Vue, and Angular, as well as Node.js applications. Its small footprint makes it an excellent choice for client-side rendering where initial load performance is critical, and its predictable nature also makes it compatible with server-side rendering environments.

With a bundle size of a mere 3.5 kB (gzipped), Day.js stands out for its performance efficiency. This extremely small size has minimal impact on application load times, which is crucial for user experience and SEO. The library is actively maintained, as evidenced by its frequent updates and substantial community traction, including 51.6 million weekly downloads and 48.7K GitHub stars, indicating a mature and reliable tool.

While Day.js is powerful for many date manipulation tasks, it consciously omits certain advanced features found in larger libraries to maintain its small size. For instance, extensive internationalization (i18n) requires separate plugins, and complex calendar calculations might necessitate a more specialized library. Developers should be aware that it is a focused tool, and for very niche or computationally intensive date operations, alternative solutions might be more appropriate.

WHEN TO USE
  • When needing to format dates for display, using its `format()` method with extensive token support.
  • For simple date parsing and manipulation tasks like adding or subtracting time units with methods like `add()` and `subtract()`.
  • To replace a larger, more memory-intensive date library while retaining a similar developer experience.
  • When building client-side applications where minimizing JavaScript bundle size is a high priority.
  • For immutable state management patterns, ensuring date objects are never mutated directly.
  • When integrating with UI components that require formatted date strings via its `toString()` or `format()` outputs.
  • To leverage its plugin system for extending functionality like RRule support or advanced timezones without increasing the core footprint.
WHEN NOT TO USE
  • If your application requires complex calendar logic or extensive i18n out-of-the-box without using additional plugins.
  • When dealing with highly complex, multi-calendar system interactions that might benefit from a more specialized library.
  • If you only need to perform extremely basic date checks without any formatting or manipulation, native JavaScript Date objects might suffice.
  • For applications where the few kilobytes saved by Day.js are utterly insignificant compared to the overall bundle size and performance constraints.
  • When needing to perform very specific, advanced date calculations that are not covered by standard manipulating methods or available plugins.
  • If you require built-in support for epoch-to-date object conversion without relying on parsing specific string formats or numbers.

CORRECTIONS

Spot wrong data here?

A short note helps us fix it.

Anonymous · No account · No email back

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