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

198
Visualizações
How to get the first day of week with year?
// result is: 2014/12/29
moment('2016/01/01').isoWeek(1).startOf('isoWeek').format("YYYY/MM/DD")

// result is: 2016/01/04
moment().year(2016).isoWeek(1).startOf('isoWeek').format("YYYY/MM/DD")

The second is right, but I don't know why the first go wrong?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

ISO week does not always start on January 1st. It might start few days before of after. https://en.wikipedia.org/wiki/ISO_week_date#First_week

The first ISO week of 2016 starts in 2016/01/04, so 2016/01/01 is in 2015 by the ISO weeks count, and moment('2016/01/01').isoWeek(1) gives the first week of 2015, that actually start few days before 2015, in 2014/12/29.

For the question in the title - the second statement with .year(2016) indeed works so you may use it.

about 4 years ago · Juan Pablo Isaza 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