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

256
Views
Converting UTC time (HH:MM) to local time

For example, if the output of the api is "13:29" and mountain daylight time is -6 UTC, how would I go about subtracting 6 from the 13 hour mark? I already have the local UTC time difference worked out below.

const date = new Date();
let timeDifference = date.getTimezoneOffset() / 60;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can get the local time by setting the UTC hours/minutes of a new date.

const utcTimeToLocalTime = (utcTime, hour12 = false) => {
  const [hour, minute] = utcTime.split(':').map(v => parseInt(v, 10));
  
  const now = new Date();
  now.setUTCHours(hour);
  now.setUTCMinutes(minute);

  return now.toLocaleTimeString('en-US', {
    hour: '2-digit',
    minute: '2-digit',
    hour12
  });
};

console.log(utcTimeToLocalTime('13:29'));       // 09:29    (EDT) or 06:29    (PDT)
console.log(utcTimeToLocalTime('13:29', true)); // 09:29 AM (EDT) or 06:29 AM (PDT)

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!