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

121
Views
How to set endDate to tomorrow in litepicker.js

I am working on building a date picker using the litepicker.js I have everything working so far but got stumped on getting the endDate to load tomorrows date. Here is what I currently have.

    new Litepicker({
    element: document.getElementById('start-date'),
    elementEnd: document.getElementById('end-date'),
    singleMode: false,
    allowRepick: true,
    format: 'D MMMM YYYY',
    startDate: new Date(),
    endDate: new Date(),
    numberOfMonths: 1,
    numberOfColumns: 1,
    tooltipText: {
        one: 'night',
        other: 'nights'
    },
    tooltipNumber: (totalDays) => {
        return totalDays - 1;
    }
});

This will show todays date on both fields, however I want the endDate to be tomorrow instead. I have tried the following

endDate: new Date(startDate.getTime() + 86400000)

and a couple other failed attempts but to no avail. Hoping the masses can assist.

Thanks in advance.

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

0

you can add a function for this.

function addDays(days) {
  let result = new Date();
  result.setDate(result.getDate() + days);
  return result;
}

so the final code looks like this.

function addDays(days) {
  let result = new Date();
  result.setDate(result.getDate() + days);
  return result;
}

const picker = new Litepicker({
    element: document.getElementById('start-date'),
    elementEnd: document.getElementById('end-date'),
    singleMode: false,
    allowRepick: true,
    format: 'D MMMM YYYY',
    startDate: new Date(),
    endDate: addDays(1),
    numberOfMonths: 1,
    numberOfColumns: 1,
    tooltipText: {
        one: 'night',
        other: 'nights'
    },
    tooltipNumber: (totalDays) => {
        return totalDays - 1;
    }
});

this should also take care of the changing month.

about 4 years ago · Juan Pablo Isaza Report

0

I was able to apparently add the variables so this can be achieved in a similar manner to a typical date change.

Here is what I added before the Litepicker script

var today = new Date();
var tomorrow = new Date(today.getTime() + 86400000); // + 1 day in ms
tomorrow.toLocaleDateString();

From there I updated the startDate and the endDate to utilize the variables created.

startDate: today,
endDate: tomorrow,

And I am successfully loading the values I want in the input fields. Thanks all

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!