how to calculate years months and days between two dates in javascript?
Now you can get any part you want. For example, how many days have elapsed between the two dates: var days = (a - b) / (60 * 60 * 24 * 1000); // 60 * 60 * 24 * 1000 is the amount of milisseconds in a day. // the variable days now equals 30.958333333333332. That's almost 31 days.