Skip to content

Instantly share code, notes, and snippets.

@bekatom
Created October 27, 2014 11:59
Show Gist options
  • Select an option

  • Save bekatom/7a12d82a93b86069320c to your computer and use it in GitHub Desktop.

Select an option

Save bekatom/7a12d82a93b86069320c to your computer and use it in GitHub Desktop.
Working With Datetimes Javascript
// Get first Date and Last Date of Current month
var date = new Date();
var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
alert(firstDay.toLocaleString()); // 10/1/2014, 12:00:00 AM
alert(lastDay.toLocaleString()); // 10/31/2014, 12:00:00 AM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment