Moment.js isAfter() Function Last Updated : 20 Mar, 2023 Comments Improve Suggest changes Like Article Like Report You can check whether a date is after a particular date in Moment.js using the isAfter() function that checks if a moment is after another moment. The first argument will be parsed as a moment, if not already so. Syntax: moment().isAfter(Moment|String|Number|Date|Array); moment().isAfter(Moment|String|Number|Date|Array, String); Parameter: It can be either Moment|String|Number|Date|Array. Returns: True or False Installation of moment module: You can visit the link to the Install moment module. You can install this package by using this command. npm install moment After installing the moment module, you can check your moment version in the command prompt using the command. npm version moment After that, you can just create a folder and add a file, for example, index.js. To run this file you need to run the following command. node index.js Project Structure: Example 1: Filename: index.js javascript // Requiring module const moment = require('moment'); let bool1 = moment('2010-10-20') .isAfter('2010-10-21'); //false console.log(bool1); let bool2 = moment('2019-10-20') .isAfter('2010-12-31', 'year'); //true console.log(bool2); Steps to run the program: Make sure you have installed the moment module using the following command: npm install moment Run the index.js file using the below command: node index.js Output: false true Example 2: Filename: index.js javascript // Requiring module const moment = require('moment'); function checkIsAfter(date1, date2) { return moment(date1).isAfter(date2); } let bool = checkIsAfter('2010-10-20', '2010-10-21'); console.log(bool); Steps to run the program: Run the index.js file using the below command: node index.js Output: false Reference: https://momentjs.com/docs/#/query/is-after/ Comment More infoAdvertise with us Next Article Moment.js isAfter() Function gouravhammad Follow Improve Article Tags : Web Technologies Node.js Moment.js Similar Reads Moment.js isDate() Function Given a value to the variable and the task is to check whether a variable is an actual date or not in Moment.js using the isDate() method. To check if a variable is a native js Date object, use moment.isDate() method. Syntax: moment.isDate(obj); Parameter: Object Returns: True or False Installati 2 min read Moment.js isSameOrAfter() Function It is used to check whether a date is the same or after a particular date in Node.js using the isSameOrAfter() function that checks if a moment is after or the same as another moment. The first argument will be parsed as a moment, if not already so. Syntax: moment().isSameOrAfter(Moment|String|Numb 2 min read Moment.js isSame() Function You can check whether a given date is equal to another date in Moment.js using isSame() function that checks if a moment is the same as another moment. The first argument will be parsed as a moment, if not already so. Syntax: moment().isSame(Moment|String|Number|Date|Array); moment().isSame(Moment| 2 min read Moment.js isDST() Function It is used to check daylight saving time in Moment.js using the isDST() function. This function checks if the current moment is in daylight saving time. Syntax: moment().isDST(); Parameter: No parameters are required. Returns: True or False Installation of moment module: You can visit the link to 2 min read Moment.js isBefore() Function It is used to check whether a date is before a particular date in Node.js using the isBefore() function that checks if a moment is before another moment. The first argument will be parsed as a moment, if not already so. Syntax: moment().isBefore(Moment|String|Number|Date|Array); moment().isBefore(M 2 min read Moment.js isLeapYear() Function It is used to check whether the given year is Leap Year or not in Moment.js using the isLeapYear() function that returns true if that year is a leap year and false if it is not. Syntax: moment().isLeapYear(); Parameter: No parameters are required. Returns: True or False Installation of moment modu 2 min read Moment.js isBetween() Function It is used to check whether a date is between a range in Moment.js using the isBetween() function that checks if a moment is between two other moments, optionally looking at unit scale (minutes, hours, days, etc). Syntax: moment().isBetween(moment-like, moment-like); moment().isBetween(moment-like, 2 min read Moment.js isDSTShifted() Function It is used to check daylight saving time-shifted in Node.js using the isDSTShifted() function. Another important thing is to know if the date has been moved by a DST. Syntax: moment('2013-03-10 2:30', 'YYYY-MM-DD HH:mm').isDSTShifted() Parameter: No parameters are required. Returns: True or False 2 min read Moment.js isMoment() Function It is used to check whether a variable is a particular moment or not in Moment.js using the isMoment() function that checks if a variable is a moment object, use moment.isMoment(). Syntax: moment.isMoment(obj); Parameter: Object Returns: True or False Installation of moment module: You can visit t 2 min read Like