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

142
Vistas
How do I change datepicker end date based on start date by 1 year

I have a standard datepicker with a Start and End date. I want the End date to increase by 1 year based on what the user selects as the start date.

Here is my Javascript code.

$("#startDate").on("change", function (e) {
  $("#endDate").val($(this).val());
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

A solution is to create a date object from the start input value and increment the year by one,
afterward, you can format and feed the modified date back in the endDate input:

$("#startDate").on("change", function(e) {
  var d = new Date($(this).val())
  d.setFullYear(d.getFullYear() + 1)

  $("#endDate").val(d.toISOString().split('T')[0]);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div>
  <p>
    start
  </p>
  <input type='date' id='startDate' placeholder='start' />
</div>


<div>
  <p>
    end
  </p>
  <input type='date' id='endDate'  />
</div>

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