create 24 hours array like 00 3a00 to 23 3a30

Solutions on MaxInterview for create 24 hours array like 00 3a00 to 23 3a30 by the best coders in the world

showing results for - "create 24 hours array like 00 3a00 to 23 3a30"
Stone
04 Nov 2017
1import moment from 'moment';
2
3export const getTimesArray = () => {
4    const hours = Array.from({
5        length: 48
6      }, (_, hour) => moment({
7          hour: Math.floor(hour / 2),
8          minutes: (hour % 2 === 0 ? 0 : 30)
9        }).format('HH:mm')
10      );
11    return hours;
12}