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
Asked
Active
Viewed 2,183 times
0
-
http://stackoverflow.com/questions/1968167/difference-between-dates-in-javascript – zmbq Jun 06 '13 at 05:08
-
please refer thin link .It may help you. http://stackoverflow.com/questions/2536379/difference-in-months-between-two-dates-in-javascript – shankar.parshimoni Jun 06 '13 at 05:08
-
1Did you put any efforts on this – vikas Jun 06 '13 at 05:13
2 Answers
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