The problem of algorithm for time period

the backend gives me a start time and an end time, gets all the hours and halves in the time period, and merges them into an array.
for example, startTime:9:30;endTime:12:00, I want to get the [9 30 Magi 10 14 00 ND 10 14 30 11 11 14 00 11 11 10 30 12 14 00], and ask God for help

May.22,2021

use the simplest while loop, with moment,starttime loop plus half an hour (with moment.js plus) every time you add to determine whether it is greater than or equal to endtime, each time you add the result push to an array, the final want is this array.

Menu