johntrepreneur johntrepreneur - 4 months ago 21
Javascript Question

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

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

Okay, I just went with the moment.js .diff() function.

myMoment.diff(yourMoment) >= 0

Close enough.