Skip to content

Instantly share code, notes, and snippets.

@thurloat
Created March 14, 2011 15:35
Show Gist options
  • Save thurloat/869322 to your computer and use it in GitHub Desktop.
Save thurloat/869322 to your computer and use it in GitHub Desktop.
Round minutes from midnight to the next 5 minute increment.
var right_now = new Date();
var raw_minutes = right_now.getHours() * 60 + right_now.getMinutes();
while (raw_minutes % 5 > 0){
raw_minutes += 1;
}
@selkhateeb
Copy link

Hello Thurloat,

IMHO, I think (raw_minutes % 5) is more efficient that the string casting and the index of stuff.

while (raw_minutes % 5) ...    

Just a thought :)

@thurloat
Copy link
Author

Your submission has been accepted ;)

-- Thanks Sam

@selkhateeb
Copy link

You are most welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment