Date Queries

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 −

MethodSyntax
Is Beforemoment().isBefore(Moment|String|Number|Date|Array);moment().isBefore(Moment|String|Number|Date|Array, String);
Is Samemoment().isSame(Moment|String|Number|Date|Array);moment().isSame(Moment|String|Number|Date|Array, String);
Is Aftermoment().isAfter(Moment|String|Number|Date|Array);moment().isAfter(Moment|String|Number|Date|Array, String);
Is Same or Beforemoment().isSameOrBefore(Moment|String|Number|Date|Array);moment().isSameOrBefore(Moment|String|Number|Date|Array, String);
Is Same or Aftermoment().isSameOrAfter(Moment|String|Number|Date|Array);moment().isSameOrAfter(Moment|String|Number|Date|Array, String);
Is Betweenmoment().isBetween(moment-like, moment-like);moment().isBetween(moment-like, moment-like, String);
Is Daylight Saving Timemoment().isDST();
Is Leap Yearmoment().isLeapYear();
Is a Momentmoment.isMoment(obj);
Is a Datemoment.isDate(obj);

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *