Math is a placeholder object that contains mathematical functions and constants of which floor() is one of these functions.
floor() function returns the largest integer value that is less than or equal to a number.
roundBody.endTime = Sat Dec 18 2021 15:00:00 GMT+0530 (India Standard Time) {}
roundBody.startTime = Sat Dec 18 2021 14:00:00 GMT+0530 (India Standard Time) {}
var timeDifference = roundBody.endTime.getTime() - roundBody.startTime.getTime();
var minutesDifference = Math.floor(timeDifference/1000/60);
var hoursDifference = Math.floor(timeDifference/1000/60/60);
var daysDifference = Math.floor(timeDifference/1000/60/60/24);
console.log("timeDifference in ms", timeDifference)
console.log("minutesDifference", minutesDifference)
console.log("hoursDifference", hoursDifference)
console.log("daysDifference", daysDifference)
output
timeDifference in ms 3600000
minutesDifference 60
hoursDifference 1
daysDifference 0
Top comments (0)