Created
October 1, 2020 12:54
-
-
Save alexalannunes/6d1624396430380ccec2fc8257b9529e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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