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

166
Views
Returning time in specific timeZone and format

I am just get started in programming, and I have a question about time. The system I am working on is set in UTC time. However, I need to return a result in US Central time 'Chicago/Americas' in a specific format YYYY-MM-DD-hh:mm:ss. I've gone down the rabbit hole on the various methods of doing this, but none seems to have exactly what I am looking for and frankly I am more confused than when I started.

The closest I've been able to get to this is this, using toLocaleString in conjunction with toISOString.

var now = new Date(new Date().toLocaleString("en-US", {timeZone: "America/Chicago"})); // returns correct Timezone, but incorrect format

var StatusTime = now.toISOString(); //returns partially correct format.

The output from this is in the correct timezone, but the formatting is not quite right, e.g. '2022-07-15T12:01:57.000Z'. This response includes the Zulu time indicator, which is incorrect. There has got to be an easier way to accomplish this. Any advice would be appreciated. Thank you in advance.

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

JS dates are annoying, so consider using a library, like https://date-fns.org/

about 4 years ago · Santiago Gelvez 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!