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