I did not see any similar questions on this site. The manpage, while helpful in describing how to use date, did not have much background info. Even the info page (as prescribed in the manpage: info '(coreutils) date invocation'), had little more than how it operates based on the TZ variable.I'm wondering how the date command line utility works. Specifically,date +%s which returns seconds since the epoch, e.g. 1467743297 (seconds since 1970-01-01 00:00:00 UTC).For example, I'm thinking it doesn't require an internet connection. Then again, does it occasionally try to re-sync with a particular source? If so, how is that source specified? If not, then how much confidence on a given machine does one have in values reported by date?Section 21.1.5 of the info page implies date only deals with the system/software clock, and then any sync with the hwclock is dependent upon the OS. So... maybe the question is more appropriately which systems have more accurate date +%s reporting? I suppose this would also imply the accuracy of date is limited to the accuracy of the machine's hardware clock, especially as influenced by the system/software clock? (e.g. the sw clock could interfere, skewing accuracy, even with a highly-accurate hw clock).
how does the gnu coreutils `date` work?
date;clock;real time;date utility
date makes no effort to synchronize with anything at all, and merely makes some system call (that on linux a strace date ... may or may not show) to lookup the time since the epoch as known by the system.The system itself may synchronize with the BIOS clock, or if a virtual machine may obtain the current time from the parent it runs under, or may use NTP (or other software that does more or less the same thing, e.g. the older rdate or instead the Precision Time Protocol (PTP)) to synchronize the time with other computers, or may use a hardware GPS or radio device to set the time from. None of these involve date, unless the admin is listening to, say, BBC Radio and manually setting the system time with date at the top of the hour (do they still do the doot doot doot dee thing at the top of the hour?).Accuracy of the system clock depends on the NTP configuration (or whatever other software is used), whether NTP (or similar) is broken, the BIOS, whether the BIOS is broken (I've seen a system boot four years into the future and that host had a broken NTP setup for other reasons, good fun, this being a NFS server with Makefile...), whether the hardware clock is misbehaving, and various other details. If you're using NTP, the peers command to ntpq or the drift file might be worth looking at.For the most accurate time (apart from putting an atomic clock on each host...) you might want to read up on PTP in Toward Higher Precision (and also learn that Time is an Illusion).