Round a Date() to the nearest 5 minutes in javascript
javascript
Solution
That's pretty simple if you already have a `Date` object:
var coeff = 1000 * 60 * 5;
var date = new Date(); //or use any other date
var rounded = new Date(Math.round(date.getTime() / coeff) * coeff)
Problem
Using a `Date()` instance, how might I round a time to the nearest five minutes? For example: if it's 4:47 p.m. it'll set the time to 4:45 p.m.