Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

160
Vistas
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 Respuestas
Responde la pregunta

0

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

about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda