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.

Peter Mortensen
  • 2,004
  • 2
  • 15
  • 18
Ninja
  • 261
  • 1
  • 2
  • 5
  • 1
    Once you get the time zones figured out, be sure to set your Pi to get the correct time from the Master Clock at the National Bureau of Standards: https://raspberrypi.stackexchange.com/questions/68811/how-do-i-set-raspbian-to-use-the-primary-time-server-time-nist-gov – SDsolar Jun 23 '17 at 00:52
  • Not worth a full answer, imo, but my issue was that my organization's wifi was blocking me from accessing internet. I thought ping google.com was working because I kept seeing responses, but I was actually getting replies from the organization rejecting me from using internet, not from google.com. TLDR: make sure you have internet access. – wxz Feb 15 '24 at 20:11

3 Answers3

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!

Jon Musselwhite
  • 774
  • 4
  • 16
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
earthmeLon
  • 1,404
  • 1
  • 11
  • 23
1

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

sudo timedatectl set-time 'yyyy-mm-dd hh-mm'
Aurora0001
  • 6,308
  • 3
  • 23
  • 38