Skip to content

Instantly share code, notes, and snippets.

@ryanisinallofus
Last active August 29, 2015 14:15
Show Gist options
  • Save ryanisinallofus/a99259446227376a8573 to your computer and use it in GitHub Desktop.
Save ryanisinallofus/a99259446227376a8573 to your computer and use it in GitHub Desktop.
getLast12MonthsFromNow1 = function() {
return _.map(_.range(12), function(n) {
return {
name: moment().subtract(n, 'month').format('MMMM'),
value: moment().subtract(n, 'month').startOf('month').format('YYYY-MM-DD')
};
});
};
getLast12MonthsFromNow2 = function() {
var months = [],
now = moment();
for (var x = 0; x < 12; x++ ) {
months.push({
name: now.format('MMMM'),
value: now.startOf('month').format('YYYY-MM-DD')
});
now.subtract(1, 'month');
}
return months;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment