Created
October 16, 2014 08:06
-
-
Save darren-rose/7466240ffa6e2912e616 to your computer and use it in GitHub Desktop.
javascript function creating an array of times every N minute intervals
This file contains hidden or 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 everyNminutes = function (n){ | |
var result = []; | |
for(var hours = 0; hours < 24; hours++){ | |
for(var minutes = 0; minutes < 60; minutes = minutes+n){ | |
var h = ''; | |
var m = ''; | |
if(hours<10){ | |
h = '0' + hours; | |
}else{ | |
h = hours; | |
} | |
if(minutes<10){ | |
m = '0' + minutes; | |
}else{ | |
m = minutes; | |
} | |
result.push(h + ':' + m); | |
} | |
} | |
return result; | |
}; | |
console.log(everyNminutes(15)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment