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

223
Views
Cómo encontrar el número de semana de un mes

Necesito encontrar cuantas semanas hay en un mes. Por ejemplo, la fecha de inicio es (24-04-2021) y la fecha de finalización es (01-05-2021). El mes de abril tiene cinco semanas, pero solo obtenemos 4 semanas como salida. esto es lo que he intentado hasta ahora

 function getWeekOfMonth(date) { const startWeekDayIndex = 1; // 1 MonthDay 0 Sundays const firstDate = new Date(date.getFullYear(), date.getMonth(), 1); const firstDay = firstDate.getDay(); let weekNumber = Math.ceil((date.getDate() + firstDay) / 7); if (startWeekDayIndex === 1) { if (date.getDay() === 0 && date.getDate() > 1) { weekNumber -= 1; } if (firstDate.getDate() === 1 && firstDay === 0 && date.getDate() > 1) { weekNumber += 1; } } return weekNumber; }
about 4 years ago · Juan Pablo Isaza
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!