Given a year and month, I'd like to determine the date of the third Friday of that month. How would I leverage moment.js to determine this?
E.g. October 2015 => 16th October 2015
Given a year and month, I'd like to determine the date of the third Friday of that month. How would I leverage moment.js to determine this?
E.g. October 2015 => 16th October 2015
Given year and month as integers and assuming that Friday is the fifth day of the week in your locale (Monday is the first day of the week), you can have:
If you have month and year as a string, you can use moment parsing functions instead of the Object notation, so you will have:
If Friday is not the fifth day of the week (day with index 4), you can get the correct index using
moment.weekdays()