0

Is there a way to get the Sunday thru Saturday dates of the week based on week number?

For example the current week number is 32, so I would want an array (or some return type) as such:

["Sunday, July 3rd, 2016", "Monday, July 4th, 2016".... etc  ] 

The documentation here states that use can use the syntax below, however this seems to simply gives me the current day (unless I'm reading the output wrong).

moment().weeks(32)

Output: Fri Aug 05 2016 11:19:39 GMT-0400

NealR
  • 10,189
  • 61
  • 159
  • 299
  • 1
    Did you install `moment js`? You can install it from npm, it's all explained at the top of the page you linked. – David Gourde Jul 08 '16 at 15:13
  • 1
    [this looks most of the way to what you need](http://stackoverflow.com/questions/16590500/javascript-calculate-date-from-week-number) – Gilad Green Jul 08 '16 at 15:16
  • The doc says: "When setting the week of the year, the day of the week is retained." – JJJ Jul 08 '16 at 15:29

1 Answers1

1

Would suggest to not go for additional libraries. Once you get first day for given week number using moment().weeks(32), write a simple method to return next seven days using moment().add() method.