Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate date from week number in moment.js

As mentioned in the title, I have a week number and a year value. Is there a way of finding Monday of that week using moment.js? Was trying, but not succeeded

like image 209
Bartosz Avatar asked Sep 24 '13 15:09

Bartosz


People also ask

How do I find the day of the week number from a moment?

$(document). ready(function(){ var weeknumber = moment("12-25-1995", "MM-DD-YYYY"). week(); console. log(weeknumber); });

How do you add a week to a date by moment?

This is a pretty robust function for adding time to an existing moment. To add time, pass the key of what time you want to add, and the amount you want to add. moment(). add(7, 'days');

Is MomentJS deprecated?

Moment construction falls back to js Date. This is discouraged and will be removed in an upcoming major release. This deprecation warning is thrown when no known format is found for a date passed into the string constructor.


1 Answers

Sorry found solution myself:

var test = moment().day("Monday").week(week number here); 
like image 199
Bartosz Avatar answered Sep 30 '22 01:09

Bartosz