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

145
Views
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 answers
Answer question

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 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!