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

206
Views
Javascript date conversion is adding an hour from 0200 to 0300 on Daylight Savings Time. I want to prevent that from happening

I hit a recent problem where I'm validating dates to make sure a start date is not greater than an end date. The dates entered are start: 3/13/2022 02:30 end: 3/13/2022 03:15

When I convert these to dates in my code an extra hour is applied to the start date making it 03:30.The end date converts as expected and remained 03:30. Because of this my validation is getting hit and we see an error stating "start date cannot be greater than end date".

Am I missing something or how do I prevent this hour from being added?

I've tried changing the format of the date, but that didn't seem to make a difference.

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

0

I think it depends on your system's local timezone, to compare those two dates, have you tried to convert them to timestamp ?

Maybe you could log the dates to the console using the date.toISOString() to see what they look like when converted to utc+0

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!