Hacker News new | ask | show | jobs
by petke 3800 days ago
I got programs connecting to servers in different countries. It was such a pain to keep the time in sync with all the different time zones and daylight savings. So i ended up using utc everywhere. i even set the clock on the wall and my wrist watch to utc. That way I'm also in sync with my programs. People who visit tell me my clocks are wrong. But i know its the the rest of the world that is wrong.
1 comments

Use unix time and NTP.
Yes. Unix time is utc based. I used manual syncing to ntp server once in a while. Automatic syncing scares me a bit. What happens when it adjust backwards in time. Programs that are running and use elapsed time logic might get very confused. Elapsed time since an event happened might become negative.
> What happens when it adjust backwards in time.

NTP deliberately makes only very tiny changes gradually when adjusting clock time backwards. Automatic updates also normally abort if the time difference would be more than 1000s (~16m). This is all fairly well-documented.

https://www.eecis.udel.edu/~mills/ntp/html/index.html

Interesting. Still any backward adjustment however small seems potentially dangerous. I googled a bit and it seems many ntp services can slow down the time until its in sync instead of adjusting it backwards. That seems safer.
Generally it isn't a backward adjustment but simply a slowing down of the clock until the 'real time' catches up. On the other side, you speed up a clock to catch up to the real time rather than catching up all at once.