Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

132
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!