Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

165
Visualizações
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 Respostas
Responde à pergunta

0

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

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda