Looking to generate a list of selectable times in 24-hour format for users to choose from. Here's an example:
Begin with: 01:00 AM 01:30 AM 02:00 AM ...
End with: 11:30 PM 00:00 AM 00:30 AM ...
Although I've tried the method below, I'm unable to achieve the desired result:
buildInitialHours() {
const hourList: any[] = [];
let hourObj = { hour: 0, minute: 0, label: '' };
for (let count = 0; count < 48; count++) {
hourObj.hour += 1;
hourObj.minute += 30;
hourObj.minute = hourObj.minute == 60 ? 30 : 30;
hourObj.label = `${hourObj.hour}:${hourObj.minute}`;
hourList.push(Object.assign({}, hourObj));
}
this.initialHours = hourList;
}