What is the method to create an array representing minute counts per hour within a specified date range?
If we have the following dates:
const initial = new Date('2019-04-04 12:14');
const final = new Date('2019-04-04 16:21');
How can we transform this into an array structured like the example below:
const minutes_per_hour = [
{
hour: 12,
minute_count: 46
},
{
hour: 13,
minute_count: 60
},
{
hour: 14,
minute_count: 60
},
{
hour: 15,
minute_count: 60
},
{
hour: 16,
minute_count: 21
}
];