Date and Time operations in JavaScript – date-fns

Complete and awesome utility library for date and time operations in JavaScript. Meet “date-fns”.

Modern date and time JS/es6 utility

The “date-fns” provides the most comprehensive, yet simple and consistent tool-set for manipulating JavaScript dates and time. Both in a browser & node.js! What the developer can find there?

Modular, Native Date (date-fns doesn’t reinvent the wheel and uses the existing native type), Immutable & Pure (date-fns is built using pure functions and always returns a new date instance instead of changing the passed one), I18n(!).

It is consistent and reliable, with very good, detailed documentation.

Date and Time operations in JavaScript - date-fns
Date and Time operations in JavaScript – date-fns


npm install date-fns --save

# or with yarn
yarn add date-fns

# or with bower
bower install date-fns


import {format, compareAsc} from 'date-fns/esm';

format(new Date(2014, 1, 11), 'MM/dd/yyyy');
//=> '02/11/2014'

const dates = [new Date(1995, 6, 2), new Date(1987, 1, 11),
                new Date(1989, 6, 10)];

//=> [
//   Wed Feb 11 1987 00:00:00,
//   Mon Jul 10 1989 00:00:00,
//   Sun Jul 02 1995 00:00:00
// ]

License: MIT




See also

Modern jQuery date picker plugin – DateSelect

Work with date and time in JavaScript? Try moment.js!

Time difference in words: jQuery fuzzy timestamps plugin – timeago

Material time picker library – a timer picker written in ES6 and SASS

jQuery countdown timer plugins

Enjoy & code!