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

103
Vistas
How work with Javascript Date timezone showing less a day

The application is based in Portugal whose timezone is UTC+00:00 but now is daylight saving.

Here I received a range of date values from the Datepicker component, which was '01/04/2022 - 01/05/2022' and saved it in a state

 const handleCreationDateChange = (dateRange: {
    startDate: Date;
    endDate: Date;
  }) => {
    if (dateRange) {
      setCreationDate(dateRange);
    } else {
      setCreationDate(null);
    }
  };

at this point, the date range object is correct, like the image below

const payload = {
    creationDateFrom: dateRange.creationDateFrom,
    creationDateTo: dateRange.creationDateTo
}

date range object

but the payload object which was sent to the server shows less a day date range object

for a user in Brasil, it shows the correct date but takes a different timezone enter image description here

I've tried converting to .toIsoString() then converting back to Date but it didn't work

this needs to work for users from different timezones

about 4 years ago · Santiago Trujillo
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