Skip to content

Instantly share code, notes, and snippets.

@ksykulev
Created June 12, 2012 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksykulev/2920501 to your computer and use it in GitHub Desktop.
Save ksykulev/2920501 to your computer and use it in GitHub Desktop.
Date Beginning and end of month
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