close

How to compare only date in moment.js

Hello Guys, How are you all? Hope You all Are Fine. Today we are going to learn How to compare only date in moment.js in javascript. So Here I am Explain to you all the possible methods here.

Without wasting your time, Let’s start This Article.

How to compare only date in moment.js ?

  1. How to compare only date in moment.js ?

    compare only date in moment.js Meanwhile you can use the isSameOrAfter method:
    moment('2010-10-20').isSameOrAfter('2010-10-20', 'day');

  2. compare only date in moment.js

    compare only date in moment.js Meanwhile you can use the isSameOrAfter method:
    moment('2010-10-20').isSameOrAfter('2010-10-20', 'day');

Method 1

Meanwhile you can use the isSameOrAfter method:

moment('2010-10-20').isSameOrAfter('2010-10-20', 'day');

Method 2

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'));

Summery

It’s all About this article. Hope all method helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which method worked for you? Thank You.

Leave a Comment