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

127
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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