0

I need to compare two dates (entered through textbox using calendar extender dd/MM/yyyy format) difference not exceed more than 3 months(90 days..)How will i do it in javascript? Thanks

2 Answers2

0

First thing that you have to do is to create a Date object from the input string. If it is like 21/11/2013, you have to do call split('/') on this string to get the day, month and year.

You can do this with the two dates and compare them.

midhunhk
  • 5,560
  • 7
  • 52
  • 83
0
function dateDiff(d1str, d2str) {
    var d1 = new Date(d1str),
        d2 = new Date(d2str);
    return (d2.getTime() - d1.getTime()) / 1000 / 60 / 60 / 24 // diff in days
}


dateDiff("11/11/2011", "11/12/2011"); // returns: 1
oluckyman
  • 3,566
  • 3
  • 28
  • 35