Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

105
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda