1.

Different ways to create an array in JavaScript?

Answer»

To COMPARE two dates in JavaScript, FIRSTLY add two date objects and SET dates.

Here, our first date is the current date:

To compare two dates in JavaScript, firstly add two date objects and set dates.

Here, our first date is the current date:

var one, two; one = new Date();         two = new Date( "MAR 10, 2017 20:15:10" );

And the second date we have set as past date:

two = new Date( "Mar 10, 2017 20:15:10" );

Now, let us compare the above two dates using the below given code:

<!DOCTYPE html> <html> <body> <script>   var one, two;   one = new Date();   document.write(one);   two = new Date( "Mar 10, 2017 20:15:10" );   document.write("<br>"+two);   if (one > two) {       document.write("<br>First date is the recent date.");   } ELSE {       document.write("<br>Second date is the recent date.");   } </script> </body> </html>


Discussion

No Comment Found