Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
¿Cómo obtener el primer y último día de la semana de la semana/año seleccionado usando Moment.js?

Tengo un año y un número de semana - YYYY[W] <-> 2022[9].

Quiero convertir aquellos que usan Moment.js para obtener el rango de fechas de esa semana específica.

  • El primer día y el último día de esa semana es la mejor solución para mi problema.
  • O también podrían funcionar todos los días de esa semana específica.

Entonces, algo como:

 function(year, week){ *convert into date range* return dateRange } //Assuming , week 9 of 2022 I should return something like ['28/02/2022','6/03/2022'] which correspond to first and last day of that week

Buscando en los documentos en este momento, buscando una solución: https://momentjs.com/docs/#/get-set/week-year/

cualquier ayuda sera bienvenida en este tema

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Asumiendo que el primer día es lunes, aquí está su solución:

 function calculateDateFromWeekNumAndYear(year, week) { const firstDate = moment().day('Monday').year(year).week(week).format('YYYY-MM-DD'); const lastDate = moment(firstDate).add(6, 'days').format('YYYY-MM-DD'); const dateRange = [firstDate, lastDate]; return dateRange; }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!