title: Get which day of week a month starts on from given input of month and year
body: <p>I have some JS code which stacks div's that are representing days in a month in a larger div that is actually a calendar. Users can freely select a month and year.  I need to build a calendar for that month.</p>
  <p>For example: if this month is starting with Saturday then I need to first build 5 empty blocks and then start filling the calendar with blocks that have a number of day inside them.</p>
  <p>How can I calculate this number for the given input of month and year?</p>
  <p><img src="https://i.stack.imgur.com/C9CJN.png" alt="" /></p>