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

148
Visualizações
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 Respostas
Responde à pergunta

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