0 votes
1 view
in Web Technology by (47.8k points)

Can someone suggest a way to compare the values of two dates greater than, less than, and not in the past using JavaScript? The values will be coming from text boxes.

1 Answer

0 votes
by (107k points)

If you want to compare two dates with JavaScript then compare them using the >, <, <= or >= operators.

If you want to use the ==, !=, ===, and !== operators then it will require you to use date.getTime() see the code below:-

var d1 = new Date();

var d2 = new Date(d1);

var same = d1.getTime() === d2.getTime();

var notSame = d1.getTime() !== d2.getTime();

Related questions

0 votes
1 answer
asked Jul 15, 2019 in SQL by Tech4ever (22.4k points)
0 votes
1 answer
asked Jul 17, 2019 in Python by Sammy (47.8k points)
0 votes
1 answer
0 votes
2 answers
0 votes
1 answer
asked Aug 10, 2019 in Java by Suresh (3.4k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...