I'm looking for a way to get tomorrow and the day after tomorrow returned from a function that receives to dates:
The current date:
2015/04/24 18:15:00
The date in the future:
2015/04/25 02:40:00
The function should return tomorrow here. I tried looking up some functions but they all return 0 not 1.
function days_between(date1, date2) {
// The number of milliseconds in one day
var ONE_DAY = 1000 * 60 * 60 * 24
// Convert both dates to milliseconds
var date1_ms = date1.getTime()
var date2_ms = date2.getTime()
// Calculate the difference in milliseconds
var difference_ms = Math.abs(date1_ms - date2_ms)
// Convert back to days and return
return Math.round(difference_ms/ONE_DAY)
}
Any ideas?