How to compare only date in moment.js

后端 未结 5 2066
余生分开走
余生分开走 2020-12-08 03:38

I am new to moment.js. I have a date object and it has some time associated with it. I just want to check if that date is greater than or equal to today\'s date,

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-08 04:02

    You could use startOf('day') method to compare just the date

    Example :

    var dateToCompare = moment("06/04/2015 18:30:00");
    var today = moment(new Date());
    
    dateToCompare.startOf('day').isSame(today.startOf('day'));
    

提交回复
热议问题