Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

203
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda