To find the time difference from a date, use the following formula in the script
var timeDiff = Math.abs(date1.getTime() - date2.getTime());
log.debug('timeDiff', timeDiff)
The formula to calculate the days
var diffDays = Math.ceil(timeDiff / (1000 3600 24));
log.debug('diffDays', diffDays)