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

292
Views
How to convert UTC offset written like this "UTC+02:00" to timestamp format?

How to convert UTC offset like this for example "UTC+02:00" to timestamp format (offset written in milliseconds)? I need to read the offset written in such way in the json file and then convert it to minutes

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

0

You can extract the values with a regular expression

/UTC([+-]\d{2}):(\d{2})/

and calculate the offset in milliseconds with

milliseconds = ((hours * 60 + minutes) * 60) * 1000

Example:

const [hours, minutes] = 'UTC-05:45'.match(/UTC([+-]\d{2}):(\d{2})/).slice(1).map(Number);

const milliseconds = Math.sign(hours) * ((Math.abs(hours) * 60 + minutes) * 60) * 1000

console.log(milliseconds);

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!