For my application is need the current datetime. But I need to round that to the nearest 10 min. I accomplished this with Math.round. The problem is that I need it to round to the LAST 10 min. Not up to the next. Because I won't have that data yet.
For example:
16:33 = 16:30 || 16:38 = 16:30 || 16:41 = 16:40
How can I do this?
const coeff = 1000 * 60 * 10;
const date = new Date(); //or use any other date
let roundDate = new Date(Math.round(date.getTime() / coeff) * coeff);