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

252
Views
Set timezone in javascript without toLocaleString

I want to set a timezone to a date. So basically a date should be display everytime taking into account that timezone. Also i want to use a native solution. I know that exists this solution:

const t = new Date(1641991591447).toLocaleString('en-GB', { timeZone: 'Europe/London' })
console.log(t)

But this returns 12/01/2022, 12:46:31 instead of 2022-01-12T12:46:31.447Z this format. So how to get the last format taking into account the timezone?

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

0

In order to convert your date to the specified format (ISO date string), you can do this by simply creating a Date constructor and using your date value as the input and chaining the toISOString method to it.

const t = new Date(1641991591447).toISOString(); // 2022-12-01T12:46:31.000Z
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!