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

129
Vistas
Get all specific day in specific end date in JavaScript

I am trying to get all day (input by me) in a specific end date (input by me).

example :

I have day 1 and I have end date 10/12/2021

beginning from new Date():

output must be: 1/10/2021 1/11/2021 1/12/2021

day 1 for this month is not included because we are in day 20 and day 20 > day 1

Same, I chose day 20 (example) and end date = 19/12/2021 day 20 in end date not included because day 20 > end date day

I have already tried that as simple using if condition, but not great work because in this case, I have 8 conditions!

I want a simple code that works for this situation.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Hope that is what you wanted. You can simplify it more if you want.

const getRemainingDates = function(beginningDay, endDate){
  const today = new Date()
  const [endDateDay,endDateMonth,endDateYear] = endDate.split("/");
  const remainingMonth = endDateMonth - (today.getMonth()+1);
  for(let i = 0; i <= remainingMonth; i++){
    if(i === 0){
        if(beginningDay>today.getDate() && beginningDay>endDateDay){
          console.log(`${beginningDay}/${today.getMonth()+1+i}/${today.getFullYear()}`)
        }
        else {}
    }
    if(i !== 0)console.log(`${beginningDay}/${today.getMonth()+1+i}/${today.getFullYear()}`)
  }
}

getRemainingDates(21,"12/12/2021");
console.log()
getRemainingDates(1,"12/12/2021");

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