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

254
Views
Why moment-timezone returns wrong utcOffset

For some timezones results that give utcOffset and moment() are different, ie for Europe/Belgrade. Currently it is GMT+2:

`Now: ${currentMoment.format()}`
// Now: 2022-06-09T12:12:08+03:00

moment.tz.zone("Europe/Belgrade").utcOffset(moment().unix())
// -60 - wrong, 1hr

moment.tz("Europe/Belgrade").format()
// 2022-06-09T11:07:03+02:00 - correct

Sandbox

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

0

Answer is here https://github.com/moment/moment-timezone/issues/989.

Instead of unix()

moment.tz.zone("Europe/Belgrade").utcOffset(moment().unix())

it is correct to use valueOf()

moment.tz.zone("Europe/Belgrade").utcOffset(moment().valueOf())
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!