JavaScript date comparison on a daily basis


The comparison of 2 Date objects in JavaScript, you can use the following function, It determines, If a date is greater on a daily basis. This is very useful, If you choose a date from a DatePicker:

function isDateInFutureOnDailyBasis(date1, date2)
{
     if(date1.getFullYear() > date2.getFullYear())
    {
        return true;
    }
    else if(date1.getFullYear() == date2.getFullYear())
     {
         if(date1.getMonth() > date2.getMonth())
         {
             return true;
         }
         else if(date1.getMonth() == date2.getMonth())
         if(date1.getDay() > date2.getDay())
         {
             return true;
         }
     }

    return false;
}