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

93
Views
how to calculate timezone offset from given timezone

I have a case where I am trying to calculate timezoneOffset from selected timezone.

The sample I am saving the time in the database as UTC format, Now I am calculating the timezone as per user's location/timezone and setting the timezone offset.

How I can create mapping that -330 offset if from which timezone, I want to calculate it for all the timezone. Example [{ timezone: 'Australia/Sydney', offset: '660' }] and so on..

such that I can search for -330 offset is for which timeozne.

Suppose -330 offset if for which timezone? Where I can create mapping with offset and timezone.

Example User a is from Australia/Sydney then how can I check timezone offset from UTC?

Just a note that I have multiple timezones to support overall more than 30 time zones.

And I want something very accurate calculation.

I know momentjs using it I can do, but suddenly don't know-how.

with momentjs I get UTCoffser of Australia/Sydney //660

Can anyone help me derive the accurate date here?

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

0

If you have the IANA name for your timezone, you can pass it into Intl.DateTimeFormat and filter out and calculate the offset:

const getUTCOffset = timezone => Intl.DateTimeFormat([], {timeZone: timezone, timeZoneName: 'shortOffset'}).formatToParts().find(o => o.type === 'timeZoneName').value.match(/\-?\d+/)[0]*60;
console.log(getUTCOffset('Australia/Sydney'))


If you're running this code in the user's browser and want to use the user's timezone, then it's even simpler:

new Date().getTimezoneOffset()
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!