I have an array arr = ['14:00', '15:00', '16:00', ...]
.
I want to rotate the array such that the time element which is closest to the actual time is first.
I have found a function to rotate an array here JavaScript Array rotate() which uses a function
function arrayRotate(arr, count) {
count -= arr.length * Math.floor(count / arr.length)
arr.push.apply(arr, arr.splice(0, count))
return arr
}
But I don't know how to determine the count argument to ensure the first element is closest to the actual time.