Skip to content

Instantly share code, notes, and snippets.

View m-lopez-f's full-sized avatar

Miguel López m-lopez-f

View GitHub Profile
@m-lopez-f
m-lopez-f / GetWeeksInMonth.js
Created January 14, 2019 10:10 — forked from markthiessen/getWeeksInMonth.js
JavaScript - get weeks in a month as array of start and end days
//note: month is 0 based, just like Dates in js
function getWeeksInMonth(month, year){
var weeks=[],
firstDate=new Date(year, month, 1),
lastDate=new Date(year, month+1, 0),
numDays= lastDate.getDate();
var start=1;
var end=7-firstDate.getDay();
while(start<=numDays){