Created
July 24, 2013 22:57
-
-
Save martindale/6075389 to your computer and use it in GitHub Desktop.
This should generate a series of 1-day timeslices for the previous 30 days (including current day).
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 start = new Date(); | |
start.setHours('0'); | |
start.setMinutes('0'); | |
start.setSeconds('0'); | |
start.setMilliseconds('0'); | |
var end = new Date( start.getTime() ); | |
end.setDate( end.getDate() + 1 ); | |
var queries = []; | |
for (var d = 30; d > 0; d--) { | |
start.setDate( start.getDate() - d ); | |
end.setDate( start.getDate() + 1 ); | |
queries.push({ | |
$gte: start | |
, $lt: end | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment