c
momentjs
👍 5
l
@ehcanadian @creece can you give a specific use case on why moment.js is needed? haven't tried it so I'm kinda curious.. also thinking of writing a newbie article about it..
c
Its really good for date manipulation and readability and takes into account all the things like leap years and whatnot. For instance to add a month, you can do new moment(new Date()).add(1, 'month'); new moment(new Date()).add(1, 'month').endOf('month'); new moment(new Date()).add(1, 'month').startOf('month'); you can add days/months/years.. start of day/month/year etc... You can also do date comparisons var dateA = new moment(new Date('1/1/2018', 'D/M/YYYY')); var dateB = new moment(new Date('2/3/2018', 'D/M/YYYY')); var isSame = dateA.isSame(dateB); var isSameOrBefore = dataA.isSameOrBefore(dateB); var isSameOrAfter = dateA.isSameOrAfter(dateB); There is also, before/after/isbetween etc... It makes your code easy to understand and you don't have to reinvent the date manipulation wheel or account for a lot of odd things in date manipulation.
s
there's also the new kid on the block
date-fns
we're considering. That said, NFT still bundles momentjs