Skip to content

Instantly share code, notes, and snippets.

@alexalannunes
Created October 1, 2020 12:54
Show Gist options
  • Select an option

  • Save alexalannunes/6d1624396430380ccec2fc8257b9529e to your computer and use it in GitHub Desktop.

Select an option

Save alexalannunes/6d1624396430380ccec2fc8257b9529e to your computer and use it in GitHub Desktop.
const moment = require("moment");
const START = 25;
const DAY = parseInt(moment().format("DD"));
let start, end;
if (DAY >= START) {
start = moment().format("YYYY-MM-25");
end = moment().add(1, "M").format("YYYY-MM-24");
} else {
start = moment().subtract(1, "M").format("YYYY-MM-25");
end = moment().format("YYYY-MM-24");
}
console.log({ start, end });
// today: 01/10/2020
// { start: '2020-09-25', end: '2020-10-24' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment