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

117
Vistas
JS Timezone not changing

I am trying to run the following code however I cannot get the correct output. This script is supposed to be able to change the date and timezone based up the parameters set, however when outputted the time will show correctly for the timezone but the timezone name will always display my local timezone despite it being referenced to use the timezone that has been set in the first time. The timezone is set for EST As you see with the code the timezone is set to EST however the "t" which displays the text version of the timezone is displaying the local timezone and now using the one specified on line one.

function init() {
  est = new Date().toLocaleString("en-us", { timeZone: "America/New_York" }); // sets timezone to EST
  d = new Date(est); // Declares a new date object
  h = d.getHours();
  m = d.getMinutes();
  s = d.getSeconds();
  t = d.toLocaleString('en-us', { timeZoneName: 'short' }).split(' ').pop();
  clock();
  day = d.getDate();
  month = d.getMonth();
  year = d.getFullYear();
};
about 4 years ago · Juan Pablo Isaza
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