how to set date and time
the date and time are set wrong on my raspberry pi does anyone know how to change it and if so could you explain it to me as i have tried and tried and have got nowhere.
-
- Posts: 4277
- Joined: Sun Jan 15, 2012 1:11 pm
Re: how to set date and time
1) How are you trying to do it?
2) Do you have a working Internet connection on the Pi? Is it present & working during the bootup?
2) Do you have a working Internet connection on the Pi? Is it present & working during the bootup?
And some folks need to stop being fanboys and see the forest behind the trees.
(One of the best lines I've seen on this board lately)
(One of the best lines I've seen on this board lately)
Re: how to set date and time
hey even i am stuck at the same, no i dont have a working net connection to the pi...may get that in 2-3 days, but till then is there ant other way to set it??
Re: how to set date and time
From a command time, do something like:
That should sort you out. For more info on the syntax of the date command:
should tell you everything you need to know.
Remember that the Raspberry Pi doesn't have a real-time clock (unless you add one yourself) so unless you're connected to the internet you'll have to set the time every time you power on or restart.
Code: Select all
sudo date -s "Thu Aug 9 21:31:26 UTC 2012"
Code: Select all
man date
Remember that the Raspberry Pi doesn't have a real-time clock (unless you add one yourself) so unless you're connected to the internet you'll have to set the time every time you power on or restart.
Re: how to set date and time
For more examples of how to set the date/time, see the Command Line Clinic in issue 2 of the free MagPi magazine.
www.themagpi.com
www.themagpi.com
Re: how to set date and time
ref: http://en.wikipedia.org/wiki/Raspberry_PiThe Raspberry Pi does not come with a real-time clock,[5] so an OS must use a network time server, or ask the user for time information at boot time to get access to time and date for file time and date stamping. However, a real-time clock (such as the DS1307) with battery backup can be added via the I2C interface.
As far as setting it, I did it at the first boot/install screen, while connected to the interwebs.
Re: how to set date and time
Hello,
If there is internet connection available follow the steps to set the date
1. sudo raspi-config
2. Internationalization options
3. Change Time Zone
4. Select geographical area
5. Select city or region.
6. Reboot your pi.
This way, you will have accurate time. Need not set the date again for every boot.
Warm Regards,
Sivakumar
If there is internet connection available follow the steps to set the date
1. sudo raspi-config
2. Internationalization options
3. Change Time Zone
4. Select geographical area
5. Select city or region.
6. Reboot your pi.
This way, you will have accurate time. Need not set the date again for every boot.
Warm Regards,
Sivakumar
Re: how to set date and time
sivakumar wrote:Hello,
If there is internet connection available follow the steps to set the date
1. sudo raspi-config
2. Internationalization options
3. Change Time Zone
4. Select geographical area
5. Select city or region.
6. Reboot your pi.
This way, you will have accurate time. Need not set the date again for every boot.
Warm Regards,
Sivakumar
Hi Sivakumar,
That's great, thanks.
btw, do you work with mysql?
thanks.
Cheers,
Bing
Re: how to set date and time
I've had problems with this too ...
I've got the Pi on the network - both using Ethernet & Wifi, and that's fine.
However, it's not updating the time. I've used the suggestion of setting the time zone (or, more to the point, tried changing it to another & back again); and have left it for about an hour, in case it needed time to think about the whole business ...
It used to work out the time - though since the last time I used it, I've updated Raspbian to, I think, the most recent (at least, the most recent that NOOBs has)
Any suggestions?
I've got the Pi on the network - both using Ethernet & Wifi, and that's fine.
However, it's not updating the time. I've used the suggestion of setting the time zone (or, more to the point, tried changing it to another & back again); and have left it for about an hour, in case it needed time to think about the whole business ...
It used to work out the time - though since the last time I used it, I've updated Raspbian to, I think, the most recent (at least, the most recent that NOOBs has)
Any suggestions?
- DougieLawson
- Posts: 40829
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: how to set date and time
ntp won't set the date/time if the current clock is off by more than 1000 seconds.
ntpd -q -g
overrides that restriction.
fake-hwclock attempts to store the clock at shutdown so that it's less likely to be that far wrong at restart.
ntpd -q -g
overrides that restriction.
fake-hwclock attempts to store the clock at shutdown so that it's less likely to be that far wrong at restart.
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Re: how to set date and time
Technically true, except that all Linux distributions start ntpd with the -g option by default. Even on systems with an RTC, it would be a bit much to expect the clock to be within 17 minutes of correct at every boot.DougieLawson wrote:ntp won't set the date/time if the current clock is off by more than 1000 seconds.
ntpd -q -g
overrides that restriction.
Re: how to set date and time
So, from what you're saying, if that is set by default (which it sounds as if it should be), then it shouldn't matter that it's been off for >17 minutes.
However, I have now discovered it must be related to the University network; I tried just now & it didn't update the time/date.
Then, got it to connect to my phone via tethering. Instantly it knew the correct time & date.
Will now try untethering & rebooting (within 17 minutes) to see if it sorts out the time.
However, I have now discovered it must be related to the University network; I tried just now & it didn't update the time/date.
Then, got it to connect to my phone via tethering. Instantly it knew the correct time & date.
Will now try untethering & rebooting (within 17 minutes) to see if it sorts out the time.
Re: how to set date and time
I have ... it didn't.
It didn't reset itself, but it just carried on from the time it had got to before I'd turned it off.
Will contact our Information Services to see if they have any ideas!

Will contact our Information Services to see if they have any ideas!
Re: how to set date and time
I spoke to a colleague, who suggested that it could be the time server. I checked my Mac & discovered its timeserver was one on our local network. So, I used the points in http://raspberrypi.stackexchange.com/qu ... -time-from & edited ntp.conf to reflect the local time server, rather than the ones in the Pi.
It now knows the time
Emma
P.S. If you're as clueless as me when it comes to linux, I used the LX Terminal & to open the file for editing, then ctrlO to save it.
It now knows the time

Emma
P.S. If you're as clueless as me when it comes to linux, I used the LX Terminal &
Code: Select all
sudo nano ntp.conf
-
- Posts: 3
- Joined: Sat Dec 06, 2014 7:11 pm
Re: how to set date and time
If you have a linux box from where you can ssh your pi, may be you could try something like this:
date -R | ssh pi@piaddress 'cat - > /home/pi/date.txt && sudo date --set="$(cat /home/pi/date.txt)" && rm /home/pi/date.txt'
this will pipe the date from your linux box to a temp file, set the date and time and remove the temp file
date -R | ssh pi@piaddress 'cat - > /home/pi/date.txt && sudo date --set="$(cat /home/pi/date.txt)" && rm /home/pi/date.txt'
this will pipe the date from your linux box to a temp file, set the date and time and remove the temp file
Last edited by joseph_curwen on Mon Dec 08, 2014 7:58 am, edited 1 time in total.
Re: how to set date and time
In general if you are using NTP to set the RPi clock you must do it in two steps:
1) Set the clock approximately correct using another program, such as ntpclient; this reads the time from an NTP server (e.g. pool.ntp.org) and forces the system clock to that time.
2) Start ntpd to do the accurate sync.
It's very important to do (1) as soon as possible in the boot sequence because until it's done files get created with bogus old dates. Some system boots have a 'swclock' approach that reads a datestamp off the file system and applies it to the system clock; this prevents time going backward on the root file system. swclock is a built-in for OpenRC.
There are multiple different implementations of ntpd however I believe they all use the kernel 'adjtime' interface and that has hardware specific limitations on how large an adjustment it can make, in addition to whatever limit the ntpd implementation imposes. It can also take a very very long time to adjust the clock, during which period the time is totally wrong; I think that's why ntpd has an extra lower limit (e.g. 1000s).
To make it worse I believe recent builds of Linux 3.17 have a bug on the B (at least) which cause time drift, maybe a few seconds in 24 hours. I haven't proved that yet to my satisfaction but if you are using 3.17 you might want to watch out for the problem; it manifests as ntp continually logging increasing drifts in the time (use dmesg).
John Bowler
1) Set the clock approximately correct using another program, such as ntpclient; this reads the time from an NTP server (e.g. pool.ntp.org) and forces the system clock to that time.
2) Start ntpd to do the accurate sync.
It's very important to do (1) as soon as possible in the boot sequence because until it's done files get created with bogus old dates. Some system boots have a 'swclock' approach that reads a datestamp off the file system and applies it to the system clock; this prevents time going backward on the root file system. swclock is a built-in for OpenRC.
There are multiple different implementations of ntpd however I believe they all use the kernel 'adjtime' interface and that has hardware specific limitations on how large an adjustment it can make, in addition to whatever limit the ntpd implementation imposes. It can also take a very very long time to adjust the clock, during which period the time is totally wrong; I think that's why ntpd has an extra lower limit (e.g. 1000s).
To make it worse I believe recent builds of Linux 3.17 have a bug on the B (at least) which cause time drift, maybe a few seconds in 24 hours. I haven't proved that yet to my satisfaction but if you are using 3.17 you might want to watch out for the problem; it manifests as ntp continually logging increasing drifts in the time (use dmesg).
John Bowler
- Nfarrow
- Posts: 48
- Joined: Sat Dec 20, 2014 1:24 am
- Location: Oklahoma, USA
- Contact: Website Facebook Twitter YouTube
Re: how to set date and time
Example code of how I set the date after changing the local time zone(sudo /usr/bin/raspi-config).
Code: Select all
sudo date -s "10 JAN 2016 20:37:00"
Twitter: @farrownick
Instagram veggievampire
I own a lot of Pis....
Instagram veggievampire
I own a lot of Pis....
-
- Posts: 30
- Joined: Wed Dec 23, 2015 3:52 pm
Re: how to set date and time
you can set time from start menu, preferences, Raspberry Pi Configuration. Also you can change the keyboard to USA so you don´t get pound symbol when hitting # key. In America we call that a hash key also.
Re: how to set date and time
is that affected by overclocking?jbowler wrote: To make it worse I believe recent builds of Linux 3.17 have a bug on the B (at least) which cause time drift, maybe a few seconds in 24 hours.
John Bowler
- DougieLawson
- Posts: 40829
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: how to set date and time
You've just replied to a post from "Sun 07 Dec 2014". The kernel has moved on a bit from there. The firmware has moved on a bit (for example, the zero is "overclocked" to 1GHz by default). It's pointless to drag up these ancient old forum threads.experix wrote:is that affected by overclocking?jbowler wrote: To make it worse I believe recent builds of Linux 3.17 have a bug on the B (at least) which cause time drift, maybe a few seconds in 24 hours.
John Bowler
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
-
- Posts: 1
- Joined: Wed Feb 24, 2016 9:53 pm
Re: how to set date and time
This is JUST the information I needed, and it worked with out a hitch! Many thanks! - Garyby sivakumar » Sun Oct 13, 2013 5:57 am
Hello,
If there is internet connection available follow the steps to set the date
1. sudo raspi-config
2. Internationalization options
3. Change Time Zone
4. Select geographical area
5. Select city or region.
6. Reboot your pi.
This way, you will have accurate time. Need not set the date again for every boot.
Warm Regards,
Sivakumar
Re: how to set date and time
Hi guys
Let's say you are connected correctly to the internet, but for example when the power goes out the Pi boots faster than the router - is there a command line to run for example 5 mins later for the Pi (Raspbian) to update the date from the time server again?
Let's say you are connected correctly to the internet, but for example when the power goes out the Pi boots faster than the router - is there a command line to run for example 5 mins later for the Pi (Raspbian) to update the date from the time server again?
Pi is not only for guys.
- DougieLawson
- Posts: 40829
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: how to set date and time
sudo /etc/init.d/ntp stop
sudo /etc/init.d/ntp start
If that doesn't work hit it harder with
sudo /etc/init.d/ntp stop
sudo ntpd -q-g
sudo /etc/init.d/ntp start
sudo /etc/init.d/ntp start
If that doesn't work hit it harder with
sudo /etc/init.d/ntp stop
sudo ntpd -q-g
sudo /etc/init.d/ntp start
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Re: how to set date and time
Once you have updated "International" settings and assuming you are connected to the Internet, go to "Network" scroll down and you will find Time! Enter "pool.ntp.org" (no quotes) reboot system and you're good to go!
Re: how to set date and time
What post are you responding to? The one from 2014?PapaRay wrote:Once you have updated "International" settings and assuming you are connected to the Internet, go to "Network" scroll down and you will find Time! Enter "pool.ntp.org" (no quotes) reboot system and you're good to go!
And where should we find
"Network"
