What it does
Moment.js is currently the de facto library for handling and manipulating dates and times. Comprehensive and probably used in all major projects requiring datetime manipulation. Supports dozens of local time formats. Works in browser and with Node.js.
License: Moment.js is free and licensed under MIT.
Popularity: Massive. npm has more than 4 million downloads per week.
- Parse dates and times
- Get/Set dates and times
- Manipulate dates and times
- Display dates and times
- Query dates and times
- Includes other date and time Utilities
- Locale support
Where to Find Moment:
[npm] – npm install moment –save
[yarn] – yarn add moment
[Nuget] – Install-Package Moment.js
var now = moment(); // get todays date/time var day = moment("2018-12-25"); // get Christmas day 2018 moment().startOf('day').fromNow(); // relative time, e.g. 5 hours ago moment().add(1, 'days').calendar(); // tomorrow. add or subtract days/weeks/months moment().format("dddd, MMMM Do YYYY, h:mm:ss a"); // format date, "Monday, May 23th 2018, 6:25:50 pm" moment('2017-09-20').isBefore('2018-01-01', 'year'); // compare - true