strict warning: Only variables should be assigned by reference in /home/itechpros/servoyguy.com/sites/all/modules/links/links.inc on line 1434.

Difference between date/time rounded up

Takes in a start and end date and calculates the difference between the time. Them rounds up to a specified interval (15 minutes in this example) and outputs as hours.

var startTime = arguments[0]
var endTime = arguments[1]
var roundInterval = 900000 //15 minutes

var timeDiff = endTime.getTime() - startTime.getTime() 
var timeIntervals = Math.ceil(timeDiff / roundInterval) 
var timeDiffInHours = (roundInterval * timeIntervals) / 3600000

return timeDiffInHours