I don't have to set the clock (besides the timezone) on the Raspberry Pi. Where is it getting the time from? About how accurate is it?
|
|
Raspbian gets the time from an NTP Server (a "time server"). Unplug your Raspberry Pi completely, pull out the network cable and start the Raspberry Pi up again. You will see that the date and time are incorrect. If you want/need the date and time to not be reset without being plugged into the internet, you'll need a Real Time Clock (RTC) - for example, something like this - which will keep the time current, by using a battery to run a clock. This is, also, how your computer keeps the time when it is not being powered. UPDATE Just a side note that the above RTC clock is not the only way to keep the time accurate between power losses. You could also use a GPS module and hook that up to the GPIO pins. Accuracy It's pretty accurate, although if your clock's time is off by quite a bit. It may take up to 3 hours to correct itself, as changes from the server are applied gradually to your local clock. Network stability has the biggest impact on the accuracy, as a unpredictable network (something more wireless, like 3G) will make it very hard to be accurate. To put it simply: The accuracy is pretty good, the time difference between your computer and the actual time (from the NTP Server) is normally less than 100ms. |
|||||||||||||||||||||
|
|
Morgan's answer gave me the hint I needed to solve the problem.
In one of my servers the date was changed inmediately. In the other I had to wait a couple of minuts. |
|||||||||||||||||||||
|
|
If you have the If you have an Internet connection (or lan with a server) and run ntp (ntpd/ntpdate), you can get the time over network, as other answers point out. When synchronized, it is really quite accurate. Online servers will also give you the consensus "world time". |
|||||||||||||||||||||
|
|
The Raspberry Pi doesn't have an integrated real time clock (RTC) for cost-effectiveness: see the question "Why is there no real time clock (RTC)?" in the official FAQ. It means that when you unplug the Raspberry Pi, it loses its time. When you power it back, the time is initialized to 1 January 1970 (aka Unix epoch). The Raspberry Pi sets its time over the network with NTP, a protocol for clock synchronization between computers. This protocol is widely used over the Internet to make sure the computers have the same time and is highly reliable since some machines are dedicated to the time calculation with atomic clocks.
|
|||||||||
|
|
If logging or keeping time when offline is what you're looking for, you may want to add a Real Time Clock chip, like the DS1307. |
|||||
|