For my upcoming project, I plan to divide the day into two-hour time slots.
start_time=10:00
end_time=24:00
The desired format for these time slots is similar to this example:
[ [10:00,12:00], [12:00,14:00], [14:00,16:00] ] ...
To achieve this, I am utilizing the following function:
function calculate_time_slot(start_time, end_time, interval = "120") {
var i, formatted_time;
var time_slots = new Array();
for (var i = start_time; i <= end_time; i = i + interval) {
formatted_time = convertHours(i);
time_slots.push(formatted_time);
}
return time_slots;
}
However, the current output is not in the desired pairing format:
[
'10:00', '12:00',
'14:00', '16:00',
'18:00', '20:00',
'22:00', '24:00'
]
I am seeking guidance on how to adjust the function to generate results in the preferred pair format like so:
[ [10:00,12:00], [12:00,14:00], [14:00,16:00] ] ...