1

How to get first day and last day of the month that user input in javascript.

Example:

userInputMonth = 01; //jan

How to get first day and last day of the user input month

  • Although a first-class duplicate, remember, that in JavaScript months are zero-based, i.e. 0: January through 11: December! – altocumulus Dec 14 '17 at 16:05

1 Answers1

0

Just use momentjs:

// Instantiate this with any moment valid date string you want
var foo = moment();
console.log(foo.endOf('month'))
console.log(foo.startOf('month'))
<script src="https://momentjs.com/downloads/moment.js"></script>
Glitcher
  • 1,078
  • 6
  • 14