MomentJS - Date Queries


Advertisements

MomentJS provides methods to query the date/time for leap year, date comparison, date validation etc. This chapter discusses them in detail.

Methods for Querying Date in MomentJS

The following table shows methods available in MomentJS and their syntax for querying date −

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);

Advertisements