Check a date is in future or past in JavaScript

Source code :

var date = new Date();

mydate=new Date('2016-09-13');

if(date < mydate)
{
    alert(" The given date is Future Date");
}
else
{
    alert("The given date is Past Date");
}

Output :

The given date is Past Date

Algorithm :

  1. First we want to find our current date
  2. To find current date the keyword is new Date()
  3. Initialize the variable for your date to check whether it is current date or not
  4. Finally print the result

Output :


                

Comments :