D = new Date();
D.setHours(D.getHours() + 12) // подвинули вперёд на 12 часов
даты корректируются «автомагически».(
(start, finish) => {
const date = new Date(start);
const dateFinish = new Date(finish);
const result = [];
while (date <= dateFinish) {
result.push(date.toISOString());
date.setHours(date.getHours() + 12);
}
return result;
}
)('2020-01-01T00:00:00+03:00', '2020-03-15T11:58:01+03:00')
/*
Array(149) [ "2019-12-31T21:00:00.000Z", "2020-01-01T09:00:00.000Z", "2020-01-01T21:00:00.000Z", "2020-01-02T09:00:00.000Z", "2020-01-02T21:00:00.000Z", "2020-01-03T09:00:00.000Z", "2020-01-03T21:00:00.000Z", "2020-01-04T09:00:00.000Z", "2020-01-04T21:00:00.000Z", "2020-01-05T09:00:00.000Z", … ]
*/