let arr = [];
for (var i=0; i<24;i++) {
arr[i] = i+':00';
}
// console.log(arr) ["0:00", "1:00", "2:00", "3:00", "4:00", "5:00", "6:00", "7:00", "8:00", "9:00", "10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00", "17:00", "18:00", "19:00", "20:00", "21:00", "22:00", "23:00"]
function arrayRotate(arr, count) {
count -= arr.length * Math.floor(count/arr.length)
arr.push.apply(arr, arr.splice(0, count))
return arr
}
let hour = new Date().getHours();
/// console.log(hour); 12
arrayRotate(arr, hour);
// console.log(arr); ["12:00", "13:00", "14:00", "15:00", "16:00", "17:00", "18:00", "19:00", "20:00", "21:00", "22:00", "23:00", "0:00", "1:00", "2:00", "3:00", "4:00", "5:00", "6:00", "7:00", "8:00", "9:00", "10:00", "11:00"]
你是什麼意思*「旋轉」*?只是把實際的時間放在前面? –