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

133
Visualizações
UTC Date Time not matching between two machines

I have two projects, one written in JS and another in Python. I have a functionality that requires to calculate the current UTC time difference coming from both projects. When I test the current UTC time I notice there is always the exact difference, and I'm expecting it to be almost equal.

The time difference calculation is done in the JS project. Using a websocket, I'm getting the UTC time from the Python project and subtract Math.round(new Date().getTime()) from it. The difference is almost always the same, but also unacceptable.

This is how I'm getting the UTC time from Python:

time = datetime.datetime.now(datetime.timezone.utc)
time = time.replace(tzinfo=datetime.timezone.utc)
time = time.timestamp()

I'm running the JS project on my windows WSL environment. When I run the python project from a local (WSL) docker container I get a difference of 7.02 seconds. When instead I run the python project from an LXC container on my raspberry pi, I'm getting around 3.04 seconds.

I need to have this difference equal down to the second. Is there something I can do about it?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I solved this using ntpdate

I have installed this package apt install ntpdate and ran ntpdate -u pool.ntp.org. What this command does it to sync your system's clock. I did this on both of my systems and I had no issues with mismatch utc timestamp.

Of course I wonder if, when JS is ran on and android device, would that system be syncronized too? I'm assuming yes for now :)

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