Created
July 12, 2013 03:57
-
-
Save codeguy/5981297 to your computer and use it in GitHub Desktop.
Round a Date to nearest Nth minute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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