let interval = 5 * 60 * 1000; // 5min in ms
let myDate = new Date(); // date that should be round to next 5min
// date with next/future 5min
let newDate = new Date(Math.ceil(myDate / interval) * interval);
// note: for NEAREST 5min interval, use Math.round()
// examples
// myDate('2022-08-11 08:01:18') -> newDate = '2022-08-11 08:05:00'
// myDate('2022-08-11 08:04:59') -> newDate = '2022-08-11 08:05:00'
// myDate('2022-08-11 08:50:08') -> newDate = '2022-08-11 08:55:00'
// myDate('2022-08-11 08:57:14') -> newDate = '2022-08-11 09:00:00'