How to do a greater than or equal to with moments (moment.js) in javascript?

johntrepreneur picture johntrepreneur · Dec 6, 2014 · Viewed 93.2k times · Source

Basically, I want to do a myMoment >= yourMoment. There is no myMoment.isSameOrAfter and writing that out combining isSame and .isAfter is a bit lengthy.

What's the alternative? Convert moment to js date and use >= to compare?

Answer

Daniel0b1b picture Daniel0b1b · Aug 2, 2016

You can use the isSameOrAfter method in momentjs:

moment1.isSameOrAfter(moment2);