compare the given date with today date using Javascript - Javascript Date Operation

Javascript examples for Date Operation:Day

Description

compare the given date with today date using Javascript

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <p id="demo"></p> 
      <p id="today"></p> 
      <p id="text"></p> 
      <script>
today = new Date();/*  w  w w .  j av  a 2s. c om*/
jan19 = new Date('2018-01-19')
document.getElementById("demo").innerHTML = jan19;
document.getElementById("today").innerHTML = today;
if (today < jan19) {
    document.getElementById("text").innerHTML = 'true';
}
else {
    document.getElementById("text").innerHTML = 'false';
}

      </script>  
   </body>
</html>

Related Tutorials