-1

Here this.startDate.value is Sun Aug 30 2020 05:30:00 GMT+0530 (India Standard Time) and this.endDate.value is Sun Aug 30 2020 00:00:00 GMT+0530 (India Standard Time). Since the time is different, comparison is working in this case.

if (moment(this.startDate.value).isAfter(moment(this.endDate.value,'day'))) {
    //
} 

Is there any way to exclude time with this above comparison.

JulienD
  • 7,102
  • 9
  • 50
  • 84
Limna
  • 17
  • 5

2 Answers2

0

You can check it in this way:

moment('2010-10-20').isAfter('2009-12-31', 'day'); // true

Also you can use year or month as granularity unit parma!

Here is a fiddle to test it.

Micha
  • 906
  • 6
  • 9
0

Worked below code:

if (moment(this.startDate.value.format('YYYY-MM-DD')).isAfter(moment(this.endDate.value).format('YYYY-MM-DD'))) {
    //..
} 
Limna
  • 17
  • 5