Created
August 10, 2018 09:41
-
-
Save finalclass/a674bb0fff4f7d018e33090b956aeac9 to your computer and use it in GitHub Desktop.
Get bounds of a month (beginning of a month and the end of a month)
This file contains 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
exports.getBeginningOfMonth = function getBeginningOfMonth(timestamp) { | |
const d = new Date(timestamp); | |
return Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), 1, 0, 0, 0, 0); | |
}; | |
exports.getEndOfMonth = function getEndOfMonth(timestamp) { | |
const d = new Date(timestamp); | |
const end = Date.UTC(d.getUTCFullYear(), d.getUTCMonth() + 1, 1, 0, 0, 0); | |
return end - 1; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment