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

107
Visualizações
How to handle BST and GMT timezones on client side? Storing them in a DB as UTC

I've got a Go app and I store all datetimes as UTC:

dateTime, err := time.Parse("2006-01-02T15:04:05.000Z", myDateTime)

This becomes something like: 2022-09-29T19:40:36.150Z.

Now I want to show this datetime client side (on a website), but showing the user the time in their timezone.

Since it's all UTC I could have the user pick their timezone from a list, like this one https://gist.github.com/valo/c07f8db33d223f57a4cc9c670e1b6050.

Then it's just a matter of adding/subtracting some time from the UTC and showing it.

But the problem is with daylight savings time, the client side timezone would have to change when it's summer, and change again when it's winter.

How are people doing this?

almost 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Usually, this happens on the client side. Information about the client's timezone is stored on the browser and is available to you if you need it. However, there are functions that sort this out automatically like toLocaleDateString.

Step 1. Parse the time string 2022-09-29T19:40:36.150Z to a Date object in javascript

Step 2. Use toLocaleDateString on the date. This will display the Date in the client's timezone setting stored in the browser

MDN docs for toLocaleDateString()

almost 4 years ago · Santiago Trujillo 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