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

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

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 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