8

The electricity to my apartment went out a few days ago.

I use my RPi to record data and store it in a database. I've just learned that the time for all my data has been off by an hour because the RPi's clock is off by an hour.

From here I issued tz select and set it to America/Los_Angeles and it is still one hour slow.

How can I adjust this?

| improve this question | | | | |
9

Sounds like a daylight saving problem.

Use raspi-config see:- http://elinux.org/RPi_raspi-config#change_timezone_-_Set_timezone

You can reset the time

sudo dpkg-reconfigure tzdata
| improve this answer | | | | |
  • Hey Milliways, I have tried raspi-config and sudo dpgk-reconfigure tzdata, but there is nothing regarding daylight savings. Am I not seeing it? – Matthew Moisen Sep 22 '13 at 2:06
  • If you have locale and timezone correctly set Linux normally does a good job of managing DST (not like Windows). File times are recorded in UTC and converted to local for dispay.There can still be issues when governments fiddle with DST. zdump -v Australia/Sydney|grep 2013 shows when times change in my home. You should check what your system says for your zone. – Milliways Sep 22 '13 at 10:02
0

It's best to store the UTC time in your database and change to localtime only for display purposes.

The main problem with storing local time is that you will get a duplicate hour when daylight saving starts, and skip an hour when daylight saving ends.

Also if you ever have users accessing from different timezones (unlikely for your particular application), it's more difficult to work out the time in the other timezone and impossible to disambiguate that hour at the start of the daylight savings.

| improve this answer | | | | |
0

The following worked for me:

sudo reboot

...

I assume that because the RPi gets the time when it is connected to the internet, my RPi booted up faster than my router, and something screwy happened.

After rebooting, the RPi is back on track.

Now I'm off to cleanse some data ...

| improve this answer | | | | |
  • 2
    Somewhat confused how this can be the accepted answer. Just because it works for you doesn't mean it works for others. – geotheory Apr 4 '14 at 10:53
  • @geotheory I tried the other answers and they didn't work for me. I found this suggestion on another site, tried it, and all was well. – Matthew Moisen Apr 5 '14 at 1:20
  • So someone else with this problem is going to find the 'accepted' answer to 'How to adjust for Daylight Savings problems?' to reboot. SO is intended to have legacy value. Its not just a helpline. – geotheory Apr 5 '14 at 8:01
  • @geotheory Alright, I see your point and unanswered my answer. However, do I just leave this post unanswered? I don't wish to award the answer to the one with the most upvotes, as that didn't solve the problem for me (whereas rebooting did). – Matthew Moisen Apr 5 '14 at 11:13
  • I'd suggest the solution by @Milliways, which seems to have worked for 4 upvoters (including myself) probably deserves the credit as it is a standard way to change the pi's time zone setting. – geotheory Apr 5 '14 at 12:19
0

Sorry to drudge up an old question; however, I recently encountered a similar problem and the various answers here suggested that we need some clarification.

I was able to reproduce the OP's problem by disconnecting power to both my router and RPi, then starting the RPi prior to the router. Under these conditions, the NTP service did not have internet access and apparently relies on the hardware clock. tzdata was correct at the time of the problem.

enter image description here

Rebooting the RPi once the internet connection was restored solved the problem. If for some reason the RPi cannot or should not be shut down, one can restart the NTP service with sudo service ntp restart.

| improve this answer | | | | |
  • Just to be clear :) the Pi doesn't have a hardware clock, although add-on boards are available to provide one. Raspbian includes the fake-hwclock package by default which, if network time is not available for some reason, restarts the clock from the time at which the machine was shut down (or some time before then in the event of power failure) at boot. – Bob Sammers Mar 28 '17 at 11:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.