Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1K
Visualizações
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

about 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Yes, it's possible:

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

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

about 4 years ago · Santiago Trujillo Relatório

0

Using startOf('isoweek') you will get the first day of the week.

moment('2017').add(13, 'weeks').startOf('week').format('DD MM YYYY'); // "02 04 2017"m, gives you Sunday(last day of the week)

moment('2017').add(13, 'weeks').startOf('isoweek').format('DD MM YYYY');
"27 03 2017"// first day of the week ( gives you Monday)
about 4 years ago · Santiago Trujillo Relatório

0

Another way is to use a format string

var dateLocale = moment(week + " " + year, "ww gggg");
var dateISO = moment(week + " " + year, "WW GGGG");
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda