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

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