date-fns Date Utility Library
github.com
3
Leaving SiteNav
External Link Disclaimer
You are about to visit github.com. This website is not operated by us. We are not responsible for its content or privacy practices.
About this website
date-fns is a free and open-source, modern JavaScript date utility library that provides the most comprehensive, yet simple and consistent toolset for manipulating JavaScript dates. Created by Sasha Koss and Lesha Koss (date-fns team) in 2015, date-fns is designed as a modern, modular, and functional alternative to Moment.js, following the success of Lodash in the utility library space. Used by over 12 million projects. Key features: modular: date-fns is built as a collection of independent functions. Each function (format, parse, addDays, subMonths, isAfter, differenceInDays) is a separate module, enabling tree-shaking. Import only what you need (import { format, addDays } from 'date-fns'). This results in significantly smaller bundle sizes compared to Moment.js (which bundles all functionality in ~70 KB). Immutable and pure: all functions are pure (no side effects) and return new Date objects, never mutating the input. This prevents bugs from accidental mutations. Functional API: functions follow a consistent data-last signature (e.g., addDays(date, amount), format(date, 'yyyy-MM-dd')). This enables currying and composition with libraries like Ramda. Comprehensive: over 200 functions covering formatting, parsing, arithmetic (add, subtract), comparison (isBefore, isAfter, isEqual), ranges (startOfDay, endOfMonth), durations, and timezone operations. Localization: built-in internationalization with over 70 locales. Import only the needed locale (import { fr } from 'date-fns/locale'). Time zones: timezone support via date-fns-tz package, which provides functions for converting between time zones using IANA timezone names. TypeScript: full TypeScript definitions. date-fns v3 supports both ESM and CommonJS. JavaScript/TypeScript. MIT.
Statistics
3
Views
0
Clicks
0
Like
0
Dislike