Skip to content

Instantly share code, notes, and snippets.

@codeguy
Created July 12, 2013 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save codeguy/5981297 to your computer and use it in GitHub Desktop.
Save codeguy/5981297 to your computer and use it in GitHub Desktop.
Round a Date to nearest Nth minute
var roundToNearestMinute = function (date) {
var coeff = 1000 * 60 * 5; // <-- Replace {5} with interval
return new Date(Math.round(date.getTime() / coeff) * coeff);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment