date-fns is a modern, lightweight, and modular JavaScript library for manipulating and formatting dates in both browsers and Node.js environments. It offers over 200 functions for common date operations, designed with a functional programming approach that ensures immutability and pure functions, returning new date instances instead of modifying existing ones.

  • Key Features:

    • Modular & Tree-shakeable: Import only the functions you need (e.g., import { format, addDays } from 'date-fns'), reducing bundle size.

    • TypeScript Support: Fully typed with handcrafted types, no additional dependencies required.

    • I18n Ready: Supports dozens of locales; include only what’s needed.

    • Native Date Usage: Works with standard JavaScript Date objects without extending core prototypes.

    • Active Maintenance: Regular updates, including v4.0 with first-class time zone support via date-fns-tz.

  • Installation:

    npm install date-fns
  • Common Usage:

    import { format, addDays } from 'date-fns';
    
    const tomorrow = addDays(new Date(), 1);
    console.log(format(tomorrow, 'dd/MM/yyyy')); // e.g., "10/03/2026"
  • vs. Moment.js: date-fns is a superior alternative—smaller, faster, immutable, and actively maintained. Moment.js is deprecated.

  • Resources:

🌐
date-fns
date-fns.org
date-fns - modern JavaScript date utility library
date-fns provides the most comprehensive yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js.
🌐
npm
npmjs.com › package › date-fns
date-fns - npm
Modern JavaScript date utility library. Latest version: 4.1.0, last published: a year ago. Start using date-fns in your project by running `npm i date-fns`. There are 24815 other projects in the npm registry using date-fns.
      » npm install date-fns
    
Published   Sep 17, 2024
Version   4.1.0
People also ask

How do I format a date using Date-fns and Moment.js?
In Moment.js, use moment().format('YYYY-MM-DD'). In Date-fns, use format(new Date(), 'yyyy-MM-dd'). Date-fns is more modular, allowing you to import only what’s needed for better performance.
🌐
staticmania.com
staticmania.com › blog › javascript-date-time-library
Working with JavaScript Date and Time Libraries: Moment.js and ...
What is the difference between Moment.js and Date-fns?
Moment.js is a legacy, large-sized library with mutability issues but provides strong time zone support. Date-fns is a modern, lightweight, immutable, and modular alternative with better performance and active maintenance.
🌐
staticmania.com
staticmania.com › blog › javascript-date-time-library
Working with JavaScript Date and Time Libraries: Moment.js and ...
When should I use Moment.js instead of Date-fns?
Use Moment.js if your project already relies on it and migration is not feasible, or if you require advanced time zone handling and built-in localization. However, for new projects, Date-fns is the better choice due to its performance and maintainability.
🌐
staticmania.com
staticmania.com › blog › javascript-date-time-library
Working with JavaScript Date and Time Libraries: Moment.js and ...
🌐
DevDocs
devdocs.io › date_fns
DevDocs — date-fns documentation
date-fns 2.29.2 API documentation with instant search, offline support, keyboard shortcuts, mobile version, and more.
🌐
Envato Tuts+
code.tutsplus.com › home › javascript
Using date-fns for Easy Date Manipulation | Envato Tuts+
July 28, 2023 - One of the primary tasks when working ... formatting dates, but it lacks support for custom formats. date-fns provides the format function for this purpose....
🌐
JavaScript in Plain English
javascript.plainenglish.io › date-manipulation-in-js-made-easy-with-date-fns-6c66706a5874
Date manipulation in JS made easy with date-fns | by Unpackaged Reviews | JavaScript in Plain English
July 28, 2020 - Date manipulation in JS made easy with date-fns Overview Ever written a method to get the time of day in GMT? or have wondered if I need to convert the time to UTC? Most applications have some common …
🌐
GitHub
github.com › date-fns › date-fns
GitHub - date-fns/date-fns: ⏳ Modern JavaScript date utility library ⌛️
date-fns provides the most comprehensive, yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js
Author   date-fns
Find elsewhere
🌐
Date-fns
blog.date-fns.org › v40-with-time-zone-support
v4.0 is out with first-class time zones support!
September 16, 2024 - In 2022, I came up with @date-fns/utc that immediately felt right. You get an option to make all the calculations in UTC and remove the local time zone from the equation without adding any extra weight to the core library.
🌐
JSFiddle
jsfiddle.net › tmtron › 31rbesxp
datefns - JSFiddle - Code Playground
JSFiddle - Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle.
🌐
StaticMania
staticmania.com › blog › javascript-date-time-library
Working with JavaScript Date and Time Libraries: Moment.js and Date-fns - StaticMania
Both Moment.js and Date-fns are powerful libraries for handling date and time operations in JavaScript. However, with Moment.js being deprecated and Date-fns offering a lightweight, modular, and immutable approach, Date-fns is the preferred choice for new projects.
🌐
DEV Community
dev.to › dmtrkovalenko › you-might-not-need-date-fns-23f7
You might not need date-fns - DEV Community
May 10, 2021 - As you can see date-fns takes 13.88kb gzip when only importing the most important functionality. It is a lot. Here is a pretty fun example of a react datepicker that has a peer dependency on date-fns. Date-fns takes 3 times more space than the datepicker itself and mostly 1/3 size of react.
🌐
Noroff
mollify.noroff.dev › content › feu1 › javascript-1 › module-6 › lesson-2 › date-fns
date-fns (Version 3)
In this lesson, we will explore the date-fns library, focusing on its version 3. This library is a modern JavaScript tool that provides a comprehensive yet straightforward set of functions for manipulating, formatting, and working with dates.
🌐
Lloyd Atkinson
lloydatkinson.net › projects › 2023 › date-fns-additional
Useful Date Time Functions - Lloyd Atkinson
January 17, 2023 - date-fns provides the most comprehensive, yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js.
🌐
SourceForge
sourceforge.net › projects › date-fns.mirror
date-fns download | SourceForge.net
Modern JavaScript date utility library. date-fns is a modern JavaScript date utility library that offers the most comprehensive toolset for manipulating JavaScript dates in a browser and Node.js.
🌐
Fulcrumapp
help.fulcrumapp.com › en › articles › 4037876-date-manipulation-with-date-fns
Date Manipulation with date-fns | Fulcrum Help Center
date-fns is a date utility library that provides a comprehensive toolset for manipulating JavaScript dates in a browser & Node.js.
🌐
GitHub
github.com › date-fns
date-fns · GitHub
Modern JavaScript date utility library. date-fns has 18 repositories available. Follow their code on GitHub.
🌐
Day.js
day.js.org
Day.js · 2kB JavaScript date utility library
Less JavaScript to download, parse and execute, leaving more time for your code · Day.js is a minimalist JavaScript library that parses, validates, manipulates, and displays dates and times for modern browsers with a largely Moment.js-compatible API
🌐
Michaelbonner
date-fns.michaelbonner.dev
date-fns format helper
A simple tool to help keep track of commonly used date formats. The tool is also helpful to test custom date formats.