Question: how to calculate date difference in js?
Answer: Assuming you have two Date objects, you can just subtract them to get the difference in milliseconds: var difference = date2 - date1; From there, you can use simple arithmetic to derive the other values. var DateDiff = { inDays: function(d1, d2) { var t2 = d2.