1

I want to get the first and last date of a month:

let month = moment().month(2)
console.log(month, month.startOf('month'), month.endOf('month'))

They all print the same date: Sat Mar 31 2018 23:59:59 GMT+0200 (W. Europe Daylight Time)

Chris
  • 13,100
  • 23
  • 79
  • 162
  • see if this helps you https://stackoverflow.com/questions/39267623/moment-js-get-first-and-last-day-of-current-month – Andrew Lohr Mar 27 '18 at 15:32
  • 3
    calling startOf modifies the object in place, so by the time it is logged, console.log is logging `month` three times, and what is being logged is the last time `month` was modified, which is calling `endOf` – chiliNUT Mar 27 '18 at 15:35

0 Answers0