Skip to content

Instantly share code, notes, and snippets.

@maggiben
Last active July 23, 2019 16:08
Show Gist options
  • Save maggiben/10d494dfa42c7646017ee45ed0d60bf5 to your computer and use it in GitHub Desktop.
Save maggiben/10d494dfa42c7646017ee45ed0d60bf5 to your computer and use it in GitHub Desktop.
Given a date and a recurrence rule show the next occurrence
var options = RRule.parseString('FREQ=MONTHLY;INTERVAL=1');
options.dtstart = moment.utc('2019-05-16 12:30:00').toDate();
options.count = 2;
var rule = new RRule(options)
var nextRun = rule.all().slice(-1).pop();
console.log(moment(nextRun).format('YYYY-MM-DD H:mm:ss'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment