如何在javascript中用moment(moment.js)做大于或等于? [英] How to do a greater than or equal to with moments (moment.js) in javascript?
本文介绍了如何在javascript中用moment(moment.js)做大于或等于?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
基本上,我想要 myMoment> = yourMoment
。没有 myMoment.isSameOrAfter
并写出结合 isSame
和 .isAfter
有点冗长。
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.
有什么替代方案?将时刻转换为js日期并使用> =
进行比较?
What's the alternative? Convert moment to js date and use >=
to compare?
推荐答案
好的,我刚刚使用了moment.js .diff()
功能。
Okay, I just went with the moment.js .diff()
function.
myMoment.diff(yourMoment)> = 0
足够近。
这篇关于如何在javascript中用moment(moment.js)做大于或等于?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文