MomentJS 提供了查询闰年,日期比较,日期验证等日期/时间的方法.本章将详细讨论它们.
在MomentJS中查询日期
下表显示了MomentJS中可用的方法及其查询日期的语法:
Method | Syntax |
---|---|
Is Before | moment().isBefore(Moment|String|Number|Date|Array); moment().isBefore(Moment|String|Number|Date|Array, String); |
Is Same | moment().isSame(Moment|String|Number|Date|Array); moment().isSame(Moment|String|Number|Date|Array, String); |
Is After | moment().isAfter(Moment|String|Number|Date|Array); moment().isAfter(Moment|String|Number|Date|Array, String); |
Is Same or Before | moment().isSameOrBefore(Moment|String|Number|Date|Array); moment().isSameOrBefore(Moment|String|Number|Date|Array, String); |
Is Same or After | moment().isSameOrAfter(Moment|String|Number|Date|Array); moment().isSameOrAfter(Moment|String|Number|Date|Array, String); |
Is Between | moment().isBetween(moment-like, moment-like); moment().isBetween(moment-like, moment-like, String); |
Is Daylight Saving Time | moment().isDST(); |
Is Leap Year | moment().isLeapYear(); |
Is a Moment | moment.isMoment(obj); |
Is a Date | moment.isDate(obj); |