I am trying to do a select box with 4 options
00,15,30,45
I want to take the current time and round it to 15 min increments, and have the value change.
I have
current_min = start_date.getMinutes();
$('#event-hour').val(current_min);
I played with this roundedMinutes=(15*Math.floor(enteredMinutes/15)) but i couldn’t get it to work right.
Use
Math.roundinstead ofMath.floorand everything should be ok– other than that, your equation for rounding to the nearestnis correct.