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

112
Views
two different dates are returned in momentjs timezone for same set time?

Even the value I set for the time in the moment.js timezones same following two different approaches the value of the date returned is different

  1. moment("02:00","HH:mm").tz('America/Chicago').format()

returns 2022-03-31T15:30:00-05:00

  1. moment().tz('America/Chicago').set({hour:"02",minute:"00"})

returns 2022-04-01T02:00:02-05:00

Can anyone please help me in understanding why is it so?

console.log(moment("02:00","HH:mm").tz('America/Chicago').format());
console.log(moment().tz('America/Chicago').set({hour:"02",minute:"00"}).format());
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.34/moment-timezone-with-data-10-year-range.js"></script>

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

0

You have different approach with two examples:

In first example you do:

  1. Take local date (2021-04-01 12:15)
  2. Set time for local date to 02:00 (2021-04-01 02:00)
  3. Move that particular local date to other time zone (so e.g. from +02:00 tz to -05:00 - moves back by 7 hours) (2021-03-31 15:00)

While in second example you do:

  1. Take local date (2021-04-01 12:15)
  2. Move that local date to other time zone (2021-04-01 06:15)
  3. Set time for moved time to 02:00 (2021-04-01 02:00)
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!