The native JavaScript Date object is not fun to work with. Moment.JS is fun to work with.
Moment give you a sane way to interact with dates in JavaScript.
Moment.JS supports JavaScript date objects, unix time, date strings, and UTC among others.
Lots of ways, it is really up to you.
My personal favorite is relative time. Relative time means it would display ‘3 minutes ago’ , ‘1 year ago’, that sort of thing.
Moment gives you the power to easily display in any format or order you want. DD MM YYYY. YYYY DD MM. Whatever you decide.
Yup, of course you can.
You can find out if two dates are equal or the order in which they occur. You can also determine is a date occurred in daylight savings time or a leap year, handy.
Moment.JS’ manipulate features let you add and subtract time. As well as set maximum and minimum date/times for date objects.
Yes, yes you should. If you want to display relative time, or display and manipulate dates from an API moment.js will make your life easier. You may think that its only a few lines of code for relative time, but there are cases you are not considering and tests you will forget to write.
Author
Originally published at www.parsed.io.