Created
June 12, 2012 22:24
-
-
Save ksykulev/2920501 to your computer and use it in GitHub Desktop.
Date Beginning and end of 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
function beginningOfMonth(date){ | |
if(typeof date === 'undefined'){ | |
date = new Date(); | |
} | |
date.setMilliseconds(0); | |
date.setSeconds(0); | |
date.setMinutes(0); | |
date.setHours(0); | |
date.setDate(1); | |
return new Date(date); | |
} | |
function endOfMonth(date){ | |
if(typeof date === 'undefined'){ | |
date = new Date(); | |
} | |
return new Date((new Date(date.getFullYear(), date.getMonth()+1,1))-1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment