I need to know the exact months that a week falls in if that week happens to be in 2 consecutive months. For example 52nd week of 2016 falls in Dec 2016 and January 2017.Also 5th week of 2017 starts on 30th January - 5th February 2017.
So given a week number in a year, can I get the months it falls in. I need to know if there is any JS library that can easily achieve this.
I know I can get a week number from a specific date value but have not seen a way to get a range of dates that date falls in so that I can derive the months from there.If momentJS or any other lib can do this, how can I use them to achieve this?
Thanks in advance
You can get week ending date easily by adding more 6 days
We want to create a date object for the beginning of a given week and the end.
momentjs is a good library to make using date objects much easier.
Given a week number, we are creating a moment object and another one six days later. Then we log the month at the beginning and end of the week.
Here's an example: