Page 1 of 1

How to change the Time

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

Many thanks

David

Re: How to change the Time

Posted: Mon Aug 06, 2012 2:51 pm
by james968
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

Re: How to change the Time

Posted: Mon Aug 06, 2012 3:06 pm
by DavidDunn
James,

Many thanks. I will try it.

David

Re: How to change the Time

Posted: Sun Sep 08, 2013 5:19 pm
by w.e. williamson jr.
Thanks for this post!

Re: How to change the Time

Posted: Sat Feb 22, 2014 8:11 am
by Hassufel
Many thanks for this post! For me it was wery useful :D

Re: How to change the Time

Posted: Sun Mar 29, 2015 9:30 am
by real1
Thank you for the information, i need to channge the clock on the raspberry pi.

Re: How to change the Time

Posted: Sun Mar 29, 2015 10:30 am
by DougieLawson
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.

Re: How to change the Time

Posted: Fri May 01, 2015 5:26 pm
by Madvillain
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)

Re: How to change the Time

Posted: Fri May 01, 2015 5:37 pm
by DougieLawson
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

Re: How to change the Time

Posted: Fri May 01, 2015 10:23 pm
by Madvillain
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.

Re: How to change the Time

Posted: Sat May 02, 2015 5:01 am
by rpdom
Does

Code: Select all

ntpq -p
Show anything useful?

Re: How to change the Time

Posted: Sat May 02, 2015 8:02 am
by DougieLawson
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.

Re: How to change the Time

Posted: Sun Oct 16, 2016 4:07 pm
by michigeo
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

Re: How to change the Time

Posted: Sun Oct 16, 2016 8:00 pm
by DougieLawson
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

Re: How to change the Time

Posted: Mon Oct 17, 2016 8:44 am
by michigeo
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.

Re: How to change the Time

Posted: Thu Nov 17, 2016 3:25 pm
by Paxman
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.)

Re: How to change the Time

Posted: Thu Nov 24, 2016 10:08 pm
by Paxman
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

Re: How to change the Time

Posted: Sun Jan 08, 2017 9:26 pm
by nastybuttler322
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.

Re: How to change the Time

Posted: Wed Jul 05, 2017 5:27 am
by annie123boy
the easiest way to do it is to sign in as pi user then go to terminal and type this in

'sudo raspi-config' then it will say

internationalization options
Change Time Zone
Select geographical area
Select city or region
Reboot your pi

Next thing you can set time using this command
sudo date -s "Mon Aug 12 20:14:11 UTC 2014"

Re: How to change the Time

Posted: Thu Jul 06, 2017 2:12 pm
by plumpi
Your Pi should set its date and time when you boot if you are using a wired ethernet connection but it will not if you are just using WiFi.

Your post has had about 50,000 views so a lot of people must be having issues with date and time, I know I did.
@Surfer Tim gave me a solution which worked it was;

Code: Select all

sudo /sbin/iptables -t mangle -I POSTROUTING 1 -o wlan0 -p udp --dport 123 -j TOS --set-tos 0x00
sudo apt-get install iptables-persistent
After doing the above I used raspi-config to change my Locale and Pixel started updating the Date and Time on boot even though the Pi only has a WiFi connection.