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

145
Visualizações
Display current users time who is in different country

Is it possible with vanilla JS to display foreign user time with his timezone?

Example:

  • ME: I am located in Prague (GMT+1)
  • USER: Is located in New York (EDT)

Current time is const localTime = 20:53 GMT+1

Current USER time is const userTime = 15:53 EDT - this is what I want to display to me: USER's time is 15:53 EDT

When USER is logged in in the beginning. I store his timezone offset: const tzOffset = new Date().getTimezoneOffset() Which returns difference from UTC in minutes.

How to with vanilla js display userTime 15:53 EDT using this tzOffset?

I have tried DateTimeFormat but options.timezone does not accept that tzOffset. And new Date has just toLocaleString().

Is there any easy way?

Edit:

Maybe better example

I have chat and there is me and the USER. If I hover over the USER I want to display a tooltip with his time with his timezone. Only what I have on my client is Date.prototype.getTimezoneOffset().

it is easy to add Hours to my current new Date() and get his time. But it is hard to display his timezone - EDT, GMT+/-X etc..

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