no

This article explains how to compare 2 Date Objects in Javascript

The best way to compare 2 Date objects using javascript is to get its long equivalent. For example we have a date in this format: mm-dd-yy...

The best way to compare 2 Date objects using javascript is to get its long equivalent.

For example we have a date in this format: mm-dd-yyyy and we want to compare them. We will declare the javascript function this way:

function compareDate(a, b) {
 var temp, from, to;
 
 from = new Date();
 temp = a.split("-");
 from.setFullYear(temp[2], temp[0] - 1, temp[1]);
 
 to = new Date();
 temp = b.split("-");
 to.setFullYear(temp[2], temp[0] - 1, temp[1]);
 
 if(from.getTime() > to.getTime()) {
  return false;
 }
 return true;
}

For setFullYear's definition:
http://www.w3schools.com/jsref/jsref_setfullyear.asp

Related

web 2979391825813565243

Post a Comment

item