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

147
Views
Convert to another time zone javascript

I have api which will give a date and timezone

{"time":"2021-01-01 10:10:10","zone":"America/Denver"}

we are not sure which timezone they are providing

How to 1)convert time to local timezone 2)convert time to another timezone

i tried

date.toLocaleString("en-US", {timeZone: "any timezone"});

but this will consider date as your local timezone only

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

To convert a date to another time zone, use the toLocaleString method

const date = new Date();

console.log(
  date.toLocaleString('en-US', {
    timeZone: 'America/New_York',
    dateStyle: 'full',
    timeStyle: 'full',
  }),
);

// result

"Sunday, April 24, 2022 at 4:42:40 AM Eastern Standard Time"

about 4 years ago · Santiago Trujillo Report

0

you can use moment js for converting zone

var jun = moment("2014-06-01T12:00:00Z");
var dec = moment("2014-12-01T12:00:00Z");

jun.tz('America/Los_Angeles').format('ha z');  // 5am PDT
dec.tz('America/Los_Angeles').format('ha z');  // 4am PST

jun.tz('America/New_York').format('ha z');     // 8am EDT
dec.tz('America/New_York').format('ha z');     // 7am EST

jun.tz('Asia/Tokyo').format('ha z');           // 9pm JST
dec.tz('Asia/Tokyo').format('ha z');           // 9pm JST

jun.tz('Australia/Sydney').format('ha z');     // 10pm EST
dec.tz('Australia/Sydney').format('ha z');     // 11pm EST
about 4 years ago · Santiago Trujillo 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!