![MomentJS Tutorial](/momentjs/images/momentjs-mini-logo.jpg)
- MomentJS Tutorial
- MomentJS - Home
- MomentJS - Overview
- MomentJS - Environment Setup
- MomentJS - Introduction
- MomentJS - Parsing Date And Time
- MomentJS - Date Validation
- MomentJS - Getter/Setter
- Manipulate Date And Time
- Formatting Date And Time
- MomentJS - Date Queries
- MomentJS - Internationalization
- MomentJS - Customization
- MomentJS - Durations
- MomentJS - Utilities
- MomentJS - Plugins
- MomentJS - Examples
- MomentJS Useful Resources
- MomentJS - Quick Guide
- MomentJS - Useful Resources
- MomentJS - Discussion
MomentJS - Is After
This method gives true or false if the given moment is after another moment.
Syntax
moment().isAfter(Moment|String|Number|Date|Array); moment().isAfter(Moment|String|Number|Date|Array, String);
Example
var isafter = moment().isAfter();
Output
![After](/momentjs/images/after.jpg)
If no param to isAfter it considers it as the current date. It gives the output as false since the current date is not after the moment compared.
Example
var isafter = moment([2015, 10, 01]).isAfter([2014, 05, 10]);
Output
![isAfter](/momentjs/images/isafter.jpg)
If the given date to isAfter is less, it gives true as the date is after the another moment.
Example
var isafter = moment([2015, 10, 01]).isAfter([2018, 05, 10]);
Output
![isAfter Less](/momentjs/images/isafter_less.jpg)
Here the date given to isAfter is greater than the date compared, so the output is false.
Consider the following examples to check isAfter() method with units.
Example
var isafter = moment([2015, 10, 01]).isAfter([2011, 05, 10], 'year');
Output
![isAfter Method](/momentjs/images/isafter_method.jpg)
momentjs_date_queries.htm
Advertisements