I’m looking for the most succinct solution to the following problem in JavaScript:
I want to determine the number of days that occur between two Dates in JavaScript. I am not looking for the date difference in Days, for example:
Date 1: June 26th 2012 11:05 PM
Date 2: June 27th 2012 12:15 AM
I was using the the following line of code:
var days = Math.ceil((date2 - date1) / 86400000);
My result is 1, I want it to be 2 (counting June 26th and June 27th)
Remove the time portion of the date and then do the date subtraction. See this jsfiddle or the snippet below.