How to change the Time


18 posts
by DavidDunn » Mon Aug 06, 2012 2:31 pm
Just got my machine and its on UK time. How do I change it? I know it must be simple but....

Many thanks

David
Posts: 4
Joined: Mon Aug 06, 2012 2:26 pm
by james968 » Mon Aug 06, 2012 2:51 pm
If you are using Raspian then there is a utility which allows you to specify the time zone and other setup otptions:
_ /usr/bin/raspi-config

If you are using a debian variation (including raspbian) you can do:
_ sudo dpkg-reconfigure tzdata

(The time is set by contacting an NTP server, so you should have working internet access for it to set the time correctly, its the TZ you need to specify)

thanks
James
Posts: 29
Joined: Tue Jul 17, 2012 8:52 am
by DavidDunn » Mon Aug 06, 2012 3:06 pm
James,

Many thanks. I will try it.

David
Posts: 4
Joined: Mon Aug 06, 2012 2:26 pm
by w.e. williamson jr. » Sun Sep 08, 2013 5:19 pm
Thanks for this post!
Posts: 1
Joined: Sun Sep 08, 2013 5:14 pm
by Hassufel » Sat Feb 22, 2014 8:11 am
Many thanks for this post! For me it was wery useful :D
Posts: 1
Joined: Sat Feb 22, 2014 8:09 am
by real1 » Sun Mar 29, 2015 9:30 am
Thank you for the information, i need to channge the clock on the raspberry pi.
User avatar
Posts: 5
Joined: Tue Jun 04, 2013 4:19 pm
by DougieLawson » Sun Mar 29, 2015 10:30 am
sudo raspi-config
has an option "internationalisation" under that menu there's a "timezone" setting.

Or just use
sudo dpkg-reconfigure tzdata

DO NOT reset the clock with a "date" command.

Four of my RPis switched to British Summer Time automagically. The other is set to stick on UTC/GMT all year round.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.
User avatar
Posts: 27904
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
by Madvillain » Fri May 01, 2015 5:26 pm
Having a similar issue, when I try sudo dpkg-reconfigure tzdata and change my timezone to 'Europe/London' it doesnt change anything. It still thinks my date and time is "Wed Feb 18 08:36 GMT 2015"

Not really sure how else to change it as I cant browse using Chromium with a wrong date apparently (certificate issues)
Posts: 8
Joined: Tue Apr 28, 2015 7:09 pm
by DougieLawson » Fri May 01, 2015 5:37 pm
What's in /etc/timezone?

What happens if you pick something like "Antarctica/McMurdo", then log out, reboot (optionally), log back in and choose your normal time zone?

Is NTP runnning to set your clock against an internet time server?

What happens if you run
sudo /etc/init.d/ntp stop
sudo ntpd -q -g
sudo /etc/init.d/ntp start
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.
User avatar
Posts: 27904
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
by Madvillain » Fri May 01, 2015 10:23 pm
Nano /etc/timezone = "Europe/London" was changed to "Antarctitica/McMurdo" rebooted and then changed back and no difference. Data is still some random day in February.

service ntp stop - was executed and it stopped the program

Code: Select all
ntpd -q -g
- was executed and it hasnt really done anything. Waited 20 minutes and then pressed CTRL C to cancel it.

I also tried sudo ntpdate-debian and apparently the socket is in use, even when NTP has been stopped ?

Could this be the route of my problem ? As I have no access to the Router Configuration I cant check if the port is blocked.
Posts: 8
Joined: Tue Apr 28, 2015 7:09 pm
by rpdom » Sat May 02, 2015 5:01 am
Does
Code: Select all
ntpq -p

Show anything useful?
User avatar
Posts: 10686
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK
by DougieLawson » Sat May 02, 2015 8:02 am
It's mostly insane Network Admins who block the ports that ntp uses, but it does happen because ntp was a security nightmare once in its chequered history.

If you really can't get ntp running then switch it out for htpdate (http://www.vervest.org). HTPDATE isn't as accurate but it uses the HTTP protocol and any reachable domain to set the time (so bypasses firewalls unless they're extremely restrictive). It pulls a web page and uses the
Code: Select all
Date: Sat, 02 May 2015 07:56:42 GMT
header that's returned. You're relying on a remote website like wikipedia.org to set their clock correctly.

You could set-up your RPi to use www.raspberrypi.org & mirrordirector.raspbian.org (if they're blocked you have other more serious issues with your Network Admin) for the time with htpdate.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.
User avatar
Posts: 27904
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
by michigeo » Sun Oct 16, 2016 4:07 pm
Hello,
I am Michael from Greece. My pi has the time set at friday 23/9/2016 09:13 how can I fix it? I can't overwrite the /etc/ntp.conf file
Posts: 8
Joined: Sat Oct 15, 2016 11:32 am
by DougieLawson » Sun Oct 16, 2016 8:00 pm
sudo /etc/init.d/ntp stop
sudo ntpd -q -g
sudo /etc/init.d/ntp start


Or stop ntp then use
sudo date -s "2016-10-16 21:00"
then restart ntp
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.
User avatar
Posts: 27904
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
by michigeo » Mon Oct 17, 2016 8:44 am
Thank you very much!! I solved it finally! (same problem with libreElec, but not so frustrating) The first line fixes the issue the second line seems to do nothing at all and not even lets me put the third line of code in terminal. It seems to me that after a complete shutdown (cause rpi3 isn't my main rig , so I have to switch cable in the monitor) the wifi cannot use ntp properly, no problems with ethernet cable.
Posts: 8
Joined: Sat Oct 15, 2016 11:32 am
by Paxman » Thu Nov 17, 2016 3:25 pm
First post here and I hope it´s OK that I continue this thread.

The clock in my raspberry have been off for some time now and today I wanted to fix this. The reason it got off I suspect is that I hade the power in my house turned off for a few hours to do some electrical stuff. After this the clock in the raspberry was off by about 10 hours. This is really inconvenient since I use the raspberry to log the heater pump for the house and I need the graphs to align with the time of day.

I first tried the "internationalization" route with no success and now I have tried all different ways that I have found on the Internet. One of these methods seem to have worked, but I was clumsy enough to change the year to 2017 (should have changed the only the date to the 17:th). Using the same method (which I now have forgot what it was) didn't work. So now I'm stuck! :cry:

The date in the Raspberry is "Fri Nov 17 14:45:51 CET 2017" and the correct time is Thu Nov 17 16:18:XX CET 2016. I am able to change the time using "sudo date -s "2016-11-17 16:18" and verifying this with "date", but when I reboot it's back to 2017 again.

Please help me to figure out what I'm doing wrong!

Update:

Further investigations has got me to suspect that this might not be something that is wrong with my equipment, nor my efforts to sort this out, but rather something with my ISP. Using the command
Code: Select all
ntpq -p
the servers in the list reports all zeros under "reach", "delay", "offset" and "jitter". Reading about this I have found others with the same problem that stated that their ISP blocked NTP-servers, and also some reported that the ISP blocked port 123.

When thinking about this one thing keeps bugging me. The reason to cut the power was that we had fiber connected to the house, and when going from ADSL and routing the new cables I had to mess around in the main electrical central. We also got a new router to the fiber and it was after this I found the problem with the time in the Raspberry. Maybe the power cut never was the culprit here. Obviously I have cut the power several times during the two years we have had the Raspberry logging the heater pump, and have never had this problem before.

I have called my ISP but their answer was that they don't block anything. Is there a way for me to confirm that the problem is with my ISP? (We did not change ISP when we got the fiber, it's the same one as we had for the ADSL.)
Posts: 2
Joined: Thu Nov 17, 2016 3:08 pm
by Paxman » Thu Nov 24, 2016 10:08 pm
Update:

This has been a headache for me for several days, but today I got help. It turned out to be a really simple fault with an easy remedy. The RP was set to a wrong gateway. Doh!

Using:

Code: Select all
sudo nano /etc/network/interfaces


I edited the gateway to the correct one. Stopped NTP with:
Code: Select all
sudo /etc/init.d/ntp stop


Changed the date manually with:
Code: Select all
sudo date -s "20xx-xx-xx xx:xx"

(where the x:s are the correct year, month, day, hour and minutes)

Started NTP with:

Code: Select all
sudo /etc/init.d/ntp start


and rebooted. Hey presto! Time is correct and I can ping the Internet! All the zeros in

Code: Select all
ntpq -p


are now numbers. All is good! :D
Posts: 2
Joined: Thu Nov 17, 2016 3:08 pm
by nastybuttler322 » Sun Jan 08, 2017 9:26 pm
james968 wrote:If you are using Raspian then there is a utility which allows you to specify the time zone and other setup otptions:
_ /usr/bin/raspi-config

If you are using a debian variation (including raspbian) you can do:
_ sudo dpkg-reconfigure tzdata

(The time is set by contacting an NTP server, so you should have working internet access for it to set the time correctly, its the TZ you need to specify)

thanks
James



Thanks dude. Weird that this must be known in order to do that on an OS that is set up for kids.
Posts: 16
Joined: Fri Dec 30, 2016 4:51 am