Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moment.JS - Get date from week number

I don't see this in the documentation of moment.js. Maybe I'm skipping over it but I want to convert a week number in a year to a date format.

for example

week: number = 13 
year: number = 2017
date: date = // get date format for the first day of that week

I'm using moment.js, but I can't find what I want in the documentation. Is this possible to do? I've found some answers for plain javascript, but since I'm already using moment.js, I figured there might be an easy way to do this

like image 496
Nicolas Avatar asked Mar 17 '17 14:03

Nicolas


1 Answers

Yes, it's possible:

var date = moment('2017').add(13, 'weeks');

Note that moment('2017') returns January 1st of 2017.

like image 98
Tomasz Rup Avatar answered Sep 23 '22 03:09

Tomasz Rup