I have connect my Raspberry Pi to LAN but there is no internet available. Is there any method to update raspberry pi date time by using a PC (windows 7) in LAN? I want to get computer date and time to my Raspberry Pi when it is booting.
In the main menu, go to Preferences > Raspberry Pi Configuration. In the “Localisation” tab, you can change the current time zone: Choose the one corresponding to your location, and click on “Ok” twice to save the changes. A few seconds later, the time should be updated in the top-right corner.
To update the packages on your Raspberry Pi, open a terminal window or connect to your Pi remotely using an SSH client. You'll first need to update the list of packages from the software repository package lists. To do this type sudo apt update, then hit enter to run it.
You can do this by opening a new terminal window and entering the command sudo rpi-eeprom-update . If it flags that an update is available, as we mentioned earlier, one option is to run sudo apt update followed by sudo apt full-upgrade to fully update your Pi's software, firmware included.
Remember that Raspberry Pi does not have real time clock. So even you are connected to internet have to set the time every time you power on or restart.
This is how it works:
sudo raspi-config
in the Raspberry Pi command lineNext thing you can set time using this command
sudo date -s "Mon Aug 12 20:14:11 UTC 2014"
More about data and time
man date
When Pi is connected to computer should have to manually set data and time
Thanks for the replies.
What I did was,
1. I install meinberg ntp software application on windows 7 pc. (softros ntp server is also possible.)
2. change raspberry pi ntp.conf file (for auto update date and time)
server xxx.xxx.xxx.xxx iburst server 1.debian.pool.ntp.org iburst server 2.debian.pool.ntp.org iburst server 3.debian.pool.ntp.org iburst
3. If you want to make sure that date and time update at startup run this python script in rpi,
import os try: client = ntplib.NTPClient() response = client.request('xxx.xxx.xxx.xxx', version=4) print "====================================" print "Offset : "+str(response.offset) print "Version : "+str(response.version) print "Date Time : "+str(ctime(response.tx_time)) print "Leap : "+str(ntplib.leap_to_text(response.leap)) print "Root Delay : "+str(response.root_delay) print "Ref Id : "+str(ntplib.ref_id_to_text(response.ref_id)) os.system("sudo date -s '"+str(ctime(response.tx_time))+"'") print "====================================" except: os.system("sudo date") print "NTP Server Down Date Time NOT Set At The Startup" pass
I found more info in raspberry pi forum.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With