16

I've a Raspberry Pi that I was using in the EST timezone. It had an NTP service installed (sudo apt-get install ntp) and the Raspberry Pi was set to the UTC timezone. The date on the Raspberry Pi was correct, until I took the Raspberry Pi to the Pacific Time Zone (PT). When I booted the Raspberry Pi, the UTC time on the Raspberry Pi was way off (behind by 9 hours), and NTP just doesn't sync to get the correct UTC time. The Raspberry Pi is connected to the Internet via Ethernet.

I've tried rebooting the Raspberry Pi several times. Also, I've tried removing the NTP service and installing OpenNTPD. What could be going on?

I'm using Raspberry Pi 3 with Raspbian Jessie.

1

3 Answers 3

23

Here are some suggestions.

  1. Use the raspi-config utility to reset the timezone even if already you used a different tool to set it.

    sudo raspi-config
    
  2. Manually set the time to be somewhat accurate. NTP sometimes won't update if the time/date is wildly wrong.

    sudo date -s "01/04/2017 11:00"
    
  3. Manually force time update:

    sudo systemctl stop ntp.service
    sudo ntpd -gqc /etc/ntpd.conf
    sudo systemctl start ntp.service
    
  4. Make sure you aren't blocking UDP port 123.

Best of luck!

1
  • 3
    File was /etc/ntp.conf on mine. May 28, 2020 at 21:58
8

In many Linux systems, the clock keeps track of time in UTC. Because of the Raspberry Pi's poor time-keeping, it's smart to install and properly setup a service to help with time, such as ntp.

This is further complicated by the fact that the Raspberry Pi has no way of keeping time while off/without power. This means when the Raspberry Pi restarts, its time will de-sync.

When you use commands such as date, which query for time, they take your locale into account. This means that date will use the timezone offset from your locale to determine local time. When you type date, you will see which timezone is being displayed:

date
Wed Jan  4 11:01:44 PST 2017

If you don't have your locale set properly, or use the -u flag, you will see:

date -u
Wed Jan  4 19:01:45 UTC 2017

When you are comparing the time and say that it's off by 6 hours, are you comparing UTC time to current UTC time, or are you comparing UTC time to the time in your timezone?

When you type date, are you shown the proper timezone? If not, you should set that up:

sudo dpkg-reconfigure tzdata # Select timezone
1

I solved this issue by setting the time manually using timedatectl, like so:

sudo timedatectl set-time 'yyyy-mm-dd hh-mm'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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