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

150
Vistas
Luxon DateTime.utc() returns different times on different devices

I've been reading for days about timezones and offsets but I can't seem to figure this out.

I have a quiz application in which the client has 5 minutes to solve a quiz. When the client sends a request to start the quiz, the server records the start_time of the quiz as that instant, and the end_time as start_time + 5min.

This end_time is sent to the browser, which then shows a countdown timer to the client by calculating the difference between the browser's current_time and the end_time. The problem is that the browser's current_time is different on different devices, even if they are in the same timezone. If a device is 2 minutes ahead of the standard time of its timezone, then its quiz ends 2 minutes earlier than every other device.

I tried using UTC time universally, on the server as well as the client, however, at the same exact instant, luxon.DateTime.utc() returns different a different time on each device. My phone's time is 2 minutes ahead of my laptop's time, and so DateTime.utc() returns, on my phone, a time that is 2 minutes ahead of that on my laptop. I don't want the device's time converted to UTC, I want an absolute time frame of reference that doesn't vary with device time.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I did not find the answer to how the method I mentioned above can be implemented, but I found another way to implement the timer.

Instead of the server sending the end_time to the browser, the server sends the remaining_time which is end_time-server_current_time. The client receives this remaining_time and sets the countdown for client_current_time+remaining_time.

about 4 years ago · Juan Pablo Isaza 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