Answers for "create 24 hours array like 00:00 to 23:30"

0

create 24 hours array like 00:00 to 23:30

import moment from 'moment';

export const getTimesArray = () => {
    const hours = Array.from({
        length: 48
      }, (_, hour) => moment({
          hour: Math.floor(hour / 2),
          minutes: (hour % 2 === 0 ? 0 : 30)
        }).format('HH:mm')
      );
    return hours;
}
Posted by: Guest on September-17-2021

Code answers related to "create 24 hours array like 00:00 to 23:30"

Code answers related to "Javascript"

Browse Popular Code Answers by Language