Skip to content

Instantly share code, notes, and snippets.

@dominikkaegi
Created October 18, 2019 09:04
Show Gist options
  • Select an option

  • Save dominikkaegi/afcc9edf6fa2eb826613cc88512e1294 to your computer and use it in GitHub Desktop.

Select an option

Save dominikkaegi/afcc9edf6fa2eb826613cc88512e1294 to your computer and use it in GitHub Desktop.
Creates a consecutive list of dates with a certain duration.
const AMOUNT_OF_DATES = 10;
const DURATION = 30;
var timeframes = []
var startDate = new Date("Fri Oct 18 2019 10:00:00 GMT+0200 (Central European Summer Time)")
for(let i = 0; i < AMOUNT_OF_DATES; i++) {
let timeframe = {
start: addMinutes(startDate, DURATION * i),
duration: DURATION
}
timeframes.push(timeframe)
}
function addMinutes(date, minutes) {
return new Date(date.getTime() + minutes*60000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment