PACKAGE · DATE & TIME

date-fns

Modern JavaScript date utility library

WEEKLY DOWNLOADS 123.1M
STARS 36.7K
FORKS 2.2K
OPEN ISSUES 1.1K
GZIP SIZE 16.9 kB
UNPACKED SIZE 10.9 MB
LAST UPDATED 1y ago
DOWNLOAD TRENDS

date-fns downloads · last 12 months

Download trends for date-fns1 download series from Nov 2025 to Oct 2026. Use left and right arrow keys to inspect monthly values.0119.5M239.0M358.4M477.9MNov 2025FebMayAugOct 2026
date-fns
ABOUT DATE-FNS

date-fns is a JavaScript library of date and time utilities for common operations such as formatting, comparison, arithmetic, and parsing. It provides functions for working with dates directly, reducing the need to write and maintain custom calendar logic throughout an application.

Its approach is to expose date operations as focused functions rather than require developers to adopt a large date-management framework. That makes date-fns suitable for JavaScript and Node.js projects that want to add specific date capabilities while keeping their application’s date handling explicit.

The API is organized around operations such as format, add, compare, and parse; for example, format can produce a display string, while date arithmetic functions can calculate a shifted date. These function-level APIs let code express the intended operation directly, and make it easier to keep formatting and calculation logic separate.

date-fns fits into JavaScript application workflows where dates enter through user input, APIs, or stored data and need to be transformed or displayed. Its topics include modules, Node.js, JavaScript, time, and utilities, so it can be used in both server-side and client-side code without requiring a particular UI framework.

The package reports a 16.9 kB gzip bundle size, while its unpacked size is 10.9 MB; those figures describe different measurements and should not be treated as interchangeable. Version 4.4.0 is MIT-licensed, and the project reports 37.3M weekly downloads and 36.6K GitHub stars, indicating substantial use, alongside 1.1K open issues. Applications with strict date, time-zone, or locale requirements should verify that the specific operations and behavior they need are covered before adopting it.

WHEN TO USE
  • Use format when application code must turn a date value into a human-readable string, and keep display formatting separate from date calculations.
  • Use date arithmetic functions such as add operations when implementing calendar-based changes without embedding custom arithmetic throughout the codebase.
  • Use comparison functions when application logic needs to check the ordering of dates or determine whether date values meet a condition.
  • Use parsing functions when converting date input into values that subsequent date-fns operations can process.
  • Add date-fns to JavaScript or Node.js workflows that need discrete utilities for date and time handling rather than a framework-specific date layer.
  • Consider its reported 16.9 kB gzip bundle size when selecting date helpers for a client-side bundle, and verify the actual functions used by your application.
WHEN NOT TO USE
  • Avoid adopting date-fns if your required date, time-zone, or locale behavior is not covered by the functions you have verified; implement or choose a solution that explicitly supports those requirements.
  • Avoid using parsing functions as a substitute for validating untrusted date input; add application-level checks for accepted formats and invalid values.
  • Avoid relying on implicit formatting behavior when an exact output string is required; specify and test the format pattern with representative dates.
  • Avoid adding the library if your runtime already provides all required date operations and your application has no need for the additional utilities; use the native date APIs directly.
  • Avoid evaluating bundle cost from the 10.9 MB unpacked size alone; compare the reported 16.9 kB gzip bundle size and measure the functions included in your own build.
  • Avoid assuming that a popular package automatically meets your maintenance or support requirements; review the reported 1.1K open issues and confirm project activity for your use case.

CORRECTIONS

Spot wrong data here?

A short note helps us fix it.

Anonymous · No account · No email back

COMPARISONS 5
date-fns vs luxon ★ 16.5K · 60.1M/wk date-fns vs moment ★ 47.9K · 51.4M/wk date-fns vs @formkit/tempo ★ 2.6K · 125.3K/wk date-fns vs dayjs ★ 48.6K · 114.1M/wk date-fns vs @js-joda/core ★ 1.7K · 7.9M/wk