The Naked Scientists
  • Login
  • Register
  • Podcasts
      • The Naked Scientists
      • eLife
      • Naked Genetics
      • Naked Astronomy
      • In short
      • Naked Neuroscience
      • Ask! The Naked Scientists
      • Question of the Week
      • Archive
      • Video
      • SUBSCRIBE to our Podcasts
  • Articles
      • Science News
      • Features
      • Interviews
      • Answers to Science Questions
  • Get Naked
      • Donate
      • Do an Experiment
      • Science Forum
      • Ask a Question
  • About
      • Meet the team
      • Our Sponsors
      • Site Map
      • Contact us

User menu

  • Login
  • Register
  • Home
  • Help
  • Search
  • Tags
  • Member Map
  • Recent Topics
  • Login
  • Register
  1. Naked Science Forum
  2. Non Life Sciences
  3. Geek Speak
  4. Why different computers/devices may show different times (at seconds precision)?
« previous next »
  • Print
Pages: [1]   Go Down

Why different computers/devices may show different times (at seconds precision)?

  • 9 Replies
  • 775 Views
  • 0 Tags

0 Members and 1 Guest are viewing this topic.

Offline remotemass (OP)

  • Jr. Member
  • **
  • 37
  • Activity:
    1%
  • Thanked: 3 times
  • Naked Science Forum Newbie
    • View Profile
Why different computers/devices may show different times (at seconds precision)?
« on: 19/06/2022 23:57:19 »
Hello,

I have a website that uses javascript to get the operating system time and display a clock on the browser. It is a completely client-side page but the problem I notice is that the operating systems in different devices will have different times. Apparently, you can use a software add-in (no advertising!) that makes your windows PC time quite accurate but to be honest I cannot trust this too much since different servers of time seem to produce different times if you want a great precision.
It seems it is definitely not possible to have milliseconds of precision in our systems these days, which is quite puzzling considering the sophistication of all our computers. Is there any reason why we are still in the stone age of precise clocks in our computers when we have the internet and so many sophisticated technologies?
I don't seem to be able to sync my static webpages that use the operating system clock when using different devices, like PC and iPhones...  Any help?

- remotemass
(My mentioned javascript static page at:
BeOmni_org)
Removed reference to a software product of unknown security... -mod
« Last Edit: 20/06/2022 09:25:13 by evan_au »
Logged
 



Offline evan_au

  • Global Moderator
  • Naked Science Forum GOD!
  • ********
  • 10350
  • Activity:
    36%
  • Thanked: 1246 times
    • View Profile
Re: Why different computers/devices may show different times (at seconds precision)?
« Reply #1 on: 20/06/2022 09:58:33 »
If you have clients in multiple timezones, you need to ensure that you are using a common time reference eg UTC (Coordinated Universal Time), rather than the local timezone, otherwise there will be time differences of hours!

Modern server-based LINUX systems have different system calls that will retrieve the system time accurate to microseconds.
- Older operating systems had system calls that only retrieved the time in operating system "ticks" of around 10ms
- Use the most appropriate system calls available on each operating system

That is fine if you are the only application running, but in most modern systems, there are many processes competing for CPU attention, so your program may be suspended for a few milliseconds (or even seconds!) while other programs get their turn.
- You can ensure that reading the time and writing database records are placed as close as possible in code, to minimize the chance of these interruptions
- On some operating systems, you can elevate the priority of your process during these time-critical sections - providing this isn't done by all processes, all the time!
- But if your database is on the other side of the world, you can expect delays of hundreds of milliseconds between the time you initiate the transaction, and the time it completes.

Most of the time-keeping protocols like NTP (Network Time Protocol) and PTP (Precision Time Protocol, IEEE1588) assume that the networks are symmetrical. If the network is not symmetrical, then the time will be off, perhaps by milliseconds. This can occur due to:
- An asymmetric network, eg Mobile phones, HFC or DSL networks, where upstream & downstream directions operate at different speeds
- It can also happen if the network is more heavily loaded downstream than upstream (although there are some mechanisms in the protocols to to detect and correct for this)

An exercise for the reader: You could write a little utility that repeatedly calls the system time function, and see what is the typical interval between returned values
- You may find that it retrieves many sequential timestamps with 0μs interval, followed by one of 10,000μs
- You may find that it normally returns values that are a few μs apart, but when the system is busy, there are gaps of many ms.
Logged
 

Offline alancalverd

  • Global Moderator
  • Naked Science Forum GOD!
  • ********
  • 14539
  • Activity:
    100%
  • Thanked: 1104 times
  • life is too short to drink instant coffee
    • View Profile
Re: Why different computers/devices may show different times (at seconds precision)?
« Reply #2 on: 20/06/2022 09:59:45 »
Internet is not instantaneous. The displayed time is probably within a millisecond of the time the server compiled it, but its route from there to your computer is not defined.

Your best estimate of UTC will be the radio signal from your national standards laboratory.
Logged
helping to stem the tide of ignorance
 

Offline Bored chemist

  • Naked Science Forum GOD!
  • *******
  • 27500
  • Activity:
    88%
  • Thanked: 928 times
    • View Profile
Re: Why different computers/devices may show different times (at seconds precision)?
« Reply #3 on: 20/06/2022 12:31:19 »
Quote from: alancalverd on 20/06/2022 09:59:45
Your best estimate of UTC will be the radio signal from your national standards laboratory.
Sort of...
I'm about 200 Km from Anthorn so the signal will get here about 0.66 mS late.
Delays on the internet will be much longer (and more variable), but my computer is clever.
It can send signals back and to and thus measure the delay, and then it can allow for it.

It's possible that my computer's idea of the time is more accurate than my "radio controlled" clock's version.
I can't compare them to anything better than 1 second or so, and they usually agree.
But both drift a bit and so, if I really want them to tally, I have to force them to "calibrate".

Logged
Please disregard all previous signatures.
 

Offline Deecart

  • Jr. Member
  • **
  • 49
  • Activity:
    24.5%
  • Thanked: 2 times
  • Naked Science Forum Newbie
    • View Profile
Re: Why different computers/devices may show different times (at seconds precision)?
« Reply #4 on: 20/06/2022 18:12:11 »
Not sure why you want to set the time of every computer using an internet connection.
If the computers are at the same local network, use one computer to get the internet time.
On this computer mount some Time servicing service and let the other computers use this value.

Here is the procedure to create your own NTP service :
https://techlibrary.hpe.com/docs/otlink-wo/How-to-Configure-a-Local-NTP-Server.html
Logged
 



Offline evan_au

  • Global Moderator
  • Naked Science Forum GOD!
  • ********
  • 10350
  • Activity:
    36%
  • Thanked: 1246 times
    • View Profile
Re: Why different computers/devices may show different times (at seconds precision)?
« Reply #5 on: 21/06/2022 03:26:28 »
Often your Internet Service Provider (ISP) will have an NTP server, whose time is set accurately across high-speed links.
- You can run NTP protocol to the ISP's NTP server. Most of the variation will occur in your connection to your ISP, which runs at the lowest speed on the path.

NTP has various tricks like:
- Measuring the time delay both ways (as mentioned by BC) and taking an average. Unfortunately, most internet access networks are not symmetrical, so the average might have an error of a few ms.
- Sending multiple messages both ways, and using the one(s) that experience the lowest delays
- Repeat this process multiple times per day. The results at 4am are likely to be more accurate than 8pm (fewer NETFLIX streams at 4am...).

There is another anomaly that affects computers occasionally: Leap Seconds
- A number of security protocols rely on accurate timestamps (to discourage replay attacks), and a leap second can make it look like a timestamp is out of date
- NTP includes advance warning of a leap second, but Leap Seconds occur so infrequently that most programmers ignore it
- To avoid this problem, Google decided to spread the leap second over 24 hours (a "leap smear"), instead of being concentrated in 1 second. That meant that Google Time was up to 0.5 seconds different from every other computer. It may have helped Google, but it probably confused some computers talking to Google!
https://developers.google.com/time/smear
Logged
 

Online SeanB

  • Naked Science Forum King!
  • ******
  • 1232
  • Activity:
    11%
  • Thanked: 13 times
    • View Profile
Re: Why different computers/devices may show different times (at seconds precision)?
« Reply #6 on: 23/06/2022 06:30:45 »
Accurate time on a PC is hard. The internal clock is run by the kernel, using a routine that is called by the 18.2Hz timer 1 interrupt, hard coded into the South bridge chipset now, but before done by a counter timer chip on the ISA bus, and with this incrementing the internal clock. This runs off the main clock, used to be 4.77MHz, derived from a roughly 14MHz clock crystal, and this would slowly drift.

Later on with Win9x you could get utilities that used NTP to slave this clock to the particular NTP pool you desired, and with XP this was built in, but by default not enabled ( you had to select it to be on), and from Win7 Microsoft ran their own NTP pool worldwide to serve a reasonably accurate clock to all computers, more for their own benefit so as to get upgrading to occur on time, and also keep Microsoft email servers synchronised, along with the mail clients.

NTP is subject to jitter, for the most case the most accurate clocks now are based on using a heavily smoothed GPS receiver at a fixed location, as GPS is by definition time based, and thus if your location is not moving, the time code received, once decoded and used to determine location, can be used to have an accurate local clock that is pretty much phased locked to the hydrogen MASER clocks that together set UTC.You use a very heavy filtering, and then use this smoothed clock to slowly trim the output of your clock, getting a time accurate to microseconds after a day or three of running, so that the residual errors can be averaged out. Used, along with a Cesium or Rubidium oscillator, to accurately set frequencies and timing for cellular networks, and also sent as part of the housekeeping data on mobile phone networks, so ironically your phone clock is the most accurate one you have.
Logged
 

Offline alancalverd

  • Global Moderator
  • Naked Science Forum GOD!
  • ********
  • 14539
  • Activity:
    100%
  • Thanked: 1104 times
  • life is too short to drink instant coffee
    • View Profile
Re: Why different computers/devices may show different times (at seconds precision)?
« Reply #7 on: 23/06/2022 22:48:21 »
And don't forget that not all countries subscribe to UTC. The legal time in Denmark, I understand, is not exactly UTC+1. 
Logged
helping to stem the tide of ignorance
 

Offline evan_au

  • Global Moderator
  • Naked Science Forum GOD!
  • ********
  • 10350
  • Activity:
    36%
  • Thanked: 1246 times
    • View Profile
Re: Why different computers/devices may show different times (at seconds precision)?
« Reply #8 on: 24/06/2022 04:13:16 »
The legal time in Darwin (which I am planning to visit next week) is not exactly UTC+9.
- It's UTC+9.5

Adelaide is also UTC+9.5
- In 6 months time, it will be UTC+10.5
- This is not due to continental drift; 6 months ago it was also UTC+10.5
Logged
 



Offline Bored chemist

  • Naked Science Forum GOD!
  • *******
  • 27500
  • Activity:
    88%
  • Thanked: 928 times
    • View Profile
Re: Why different computers/devices may show different times (at seconds precision)?
« Reply #9 on: 24/06/2022 08:59:12 »
Quote from: alancalverd on 23/06/2022 22:48:21
The legal time in Denmark, I understand, is not exactly UTC+1. 
It was when I went to Legoland.
Logged
Please disregard all previous signatures.
 



  • Print
Pages: [1]   Go Up
« previous next »
Tags:
 

Similar topics (5)

Do the results of NIST 2010 relativity test show same result as Pound Rebka?

Started by Colin2BBoard Physics, Astronomy & Cosmology

Replies: 19
Views: 7689
Last post 05/12/2016 11:45:00
by nilak
Why do recovery times post-op vary from person to person?

Started by thedocBoard Physiology & Medicine

Replies: 2
Views: 4916
Last post 07/11/2019 14:06:57
by exothermic
If uranium atoms were 3 times smaller, would uranium-238 still be non-fissile?

Started by granpaBoard General Science

Replies: 8
Views: 4379
Last post 16/07/2017 00:57:25
by PmbPhy
What was the incendiary "Greek Fire" used in medieval times?

Started by i am boredBoard Chemistry

Replies: 26
Views: 35933
Last post 27/09/2016 02:00:11
by William McC
If Tunguska was "2,000 times stronger" than the a-bombs, how did Earth survive?

Started by Pseudoscience-is-malarkeyBoard Physics, Astronomy & Cosmology

Replies: 9
Views: 4998
Last post 21/07/2021 17:43:05
by Bored chemist
There was an error while thanking
Thanking...
  • SMF 2.0.15 | SMF © 2017, Simple Machines
    Privacy Policy
    SMFAds for Free Forums
  • Naked Science Forum ©

Page created in 0.148 seconds with 59 queries.

  • Podcasts
  • Articles
  • Get Naked
  • About
  • Contact us
  • Advertise
  • Privacy Policy
  • Subscribe to newsletter
  • We love feedback

Follow us

cambridge_logo_footer.png

©The Naked Scientists® 2000–2017 | The Naked Scientists® and Naked Science® are registered trademarks created by Dr Chris Smith. Information presented on this website is the opinion of the individual contributors and does not reflect the general views of the administrators, editors, moderators, sponsors, Cambridge University or the public at large.