It's a snaphot of in datetime 2017-07-31 07:16:37, It has nothing to do with the author of this page. change to Full Edition
date-fns - modern JavaScript date utility library

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.


import { format, formatDistance, formatRelative, subDays } from 'date-fns'
format(new Date(), '[Today is a] dddd')
//=> "Today is a Monday"
formatDistance(subDays(new Date(), 3), new Date())
//=> "3 days ago"
formatRelative(subDays(new Date(), 3), new Date())
//=> "last Friday at 7:26 p.m."

Why date-fns?

  1. Modular

    With the function-per-file style, you can pick just what you need and stop bloating your project with useless functionality.

    It works well with modern module bundlers such as webpack, Browserify, or Rollup and also supports tree-shaking.

  2. Native Date

    date-fns doesn't reinvent the wheel and uses the existing native type. Also, it doesn't extend core objects for safety sake.

    Functions in date-fns work predictable and stick to ECMAScript behavior in edge cases.

  3. Immutable & Pure

    date-fns is built using pure functions and always returns a new date instance instead of changing the passed one.

    It allows to prevent bugs and skip long debugging sessions.

  4. TypeScript & Flow

    date-fns supports both Flow and TypeScript.

    The typings are generated from the source code and bundled with the package, so they always up-to-date.

  5. FP

    The functional programming submodule provides a better alternative to chaining — composition, which makes your code clean, safe and doesn't bloat your build.

  6. I18n

    With the support of an amazing community, date-fns have dozens of locales. But none of them will be included in your build unless you use that.

  7. Consistent

    It always returns a date in the same time zone, no matter what's passed, a timestamp, a string or a date object.

    The API is tailored to have predictable names and arguments order.

  8. Reliable

    date-fns respects timezones & DST.

    It follows semantic versioning so, always backward compatible.

    Each build CI checks more than 650 000 examples in about 400 time zones.

  9. Simple

    The best API is an API that doesn't exist. With date-fns you always have one function that does one thing.

    The API is unambiguous, and there is always a single approach to a problem.

  10. Fast

    In addition to tiny size, date-fns is fast. You can be sure that your users will have the best user experience.

  11. Docs

    Every date-fns has detailed description with examples. The documentation is accessible both online, at the website, and offline thank to JSDoc annotations.

  12. More Coming!

    date-fns is an active development and we have plans to add more features.


date-fns is the modular path to date/time manipulation. Where I work, it helped us get our bundle sizes down, especially because we are able to include only the functionality we need.
date-fns gave us the power to work directly with date objects, without worrying about conversion or mutations. It's a real game changer for dates.
Sasha and Lesha Koss made what anyone dealing with dates in JS ever wanted, but didn’t got the time, the knowledge or the courage! Because of stars like date-fns the dev community is becoming an amazing universe. Thank you!
Leave Your Feedback


Want to become a project sponsor, add your (company) name to the hall of fame and support the developers?
Sponsor date-fns