User avatar
micksulley
Posts: 166
Joined: Sat Mar 03, 2012 11:48 am
Location: Melton Mowbray, England

How to set time/date without internet

Tue May 02, 2017 2:01 pm

I know this sounds a bit odd, but I want to disable time/date setting and update from the internet and do it manually. The reason is that I am developing an alarm clock (with various other features) based on a Pi Zero, and I want it to be usable if there is no internet connection. The development Pi is running headless, development on my desktop, so I cannot just disable the network.

I thought it would be easy, but don't really know how to do it! Ideas, suggestions?

Thanks
Mick

fruitoftheloom
Posts: 21574
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: How to set time/date without internet

Tue May 02, 2017 2:05 pm

micksulley wrote:I know this sounds a bit odd, but I want to disable time/date setting and update from the internet and do it manually. The reason is that I am developing an alarm clock (with various other features) based on a Pi Zero, and I want it to be usable if there is no internet connection. The development Pi is running headless, development on my desktop, so I cannot just disable the network.

I thought it would be easy, but don't really know how to do it! Ideas, suggestions?

Thanks
Mick
Maybe something like this ???

https://shop.pimoroni.com/products/adaf ... spberry-pi
Retired disgracefully.....
......to a more gentile life !

User avatar
micksulley
Posts: 166
Joined: Sat Mar 03, 2012 11:48 am
Location: Melton Mowbray, England

Re: How to set time/date without internet

Tue May 02, 2017 2:11 pm

No sorry, what I meant was how to disable internet update, so I can let the user set it, just like a standard digital alarm clock.

User avatar
RaTTuS
Posts: 10530
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: How to set time/date without internet

Tue May 02, 2017 2:35 pm

you use the command date
i.e.
sudo date -s 2017-02-05 15:30:0
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
micksulley
Posts: 166
Joined: Sat Mar 03, 2012 11:48 am
Location: Melton Mowbray, England

Re: How to set time/date without internet

Tue May 02, 2017 3:06 pm

Thanks.
I had to put the time date in quotes
sudo date -s '2017-02-05 15:30:00'
but it does the job.

W. H. Heydt
Posts: 11434
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: How to set time/date without internet

Tue May 02, 2017 3:27 pm

I have a Pi "travel alarm", and--yes--an internet connection isn't always available.

Two points...first, you don't need to disable NTP in order to set the date manually when there is no internet connection. That way, when there *is* an internet connection, it will set itself automatically. Second...if you add an RTC to your Pi, it will get the time from that when it boots (and if an internet connection is available, it will update with a more accurate time). On a Pi0 you will need to find a way to connect the RTC. One way is to add the header pins the RTC needs. Another is to solder wires from the RTC board to the GPIO holes on the Pi0. (On the one Pi0 I have with an RTC, I have used the former method.)

jmsbc
Posts: 1
Joined: Tue Oct 10, 2017 6:50 pm

Re: How to set time/date without internet

Tue Oct 10, 2017 6:52 pm

Hi,

I am able to set the date and time using the above example. However, if I manually set the date/time to an earlier time (without internet) and reboot, it will not save the date/time I entered because it was earlier than what it was previously set to.

How do I bypass this internal check?

Thanks

Return to “Beginners”