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

118
Visualizações
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 à 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