Originally published at https://github.com
date-fns is like lodash for dates. It has 180+ functions for all occasions.
import { compareAsc, format } from 'date-fns'format(new Date(2014, 1, 11), ‘yyyy-MM-dd’)
//=> ‘2014-02-11’const dates = [
new Date(1995, 6, 2),
new Date(1987, 1, 11),
new Date(1989, 6, 10)
]
dates.sort(compareAsc)
//=> [
// Wed Feb 11 1987 00:00:00,
// Mon Jul 10 1989 00:00:00,
// Sun Jul 02 1995 00:00:00
// ]
The library is available as an npm package. To install the package run:
npm install date-fns --saveor with yarn
yarn add date-fns
See date-fns.org for more details, API, and other docs.
Thanks for reading ❤
If you liked this post, please do share/like it with all of your programming buddies!
Follow us on Facebook | Twitter
☞ The Complete JavaScript Course 2019: Build Real Projects!
☞ Vue JS 2 - The Complete Guide (incl. Vue Router & Vuex)
☞ JavaScript Bootcamp - Build Real World Applications
☞ JavaScript Programming Tutorial - Full JavaScript Course for Beginners
☞ New ES2019 Features Every JavaScript Developer Should Know
☞ Best JavaScript Frameworks, Libraries and Tools to Use in 2019
☞ JavaScript Basics Before You Learn React
☞ Build a CMS with Laravel and Vue
☞ Google’s Go Essentials For Node.js / JavaScript Developers
☞ 7 best JavaScript Design Patterns You Should Know
☞ Best 50 Nodejs interview questions from Beginners to Advanced in 2019
☞ Node.js 12: The future of server-side JavaScript
☞ An Introduction to Node.js Design Patterns
☞ Basic Server Side Rendering with Vue.js and Express
#javascript #node-js