TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: ALL
from: R.WIESER
date: 2019-11-02 16:14:00
subject: Python - set current time

Hello all,

Just today I connected a DS3231 Real Time Clock module to my Pi - to use
when it cannot connect to the internet to get its current time from an NTP
server..

I'm using python to retrieve the date and time from the RTC module and
display it. But now I'm stuck at the point where I need to set Raspberry
Pi's clock with it.  I've been googeling for at least half an hour, but
can't seem to find how to *set* the current time.

De closest I have been is to execute
"datetime.datetime(2019,11,02,16,06,0) - which gets ignored without any kind
of error or warning message ...

Added problem: The Pi might (ofcourse) have problems with "a mere user"
trying to change the system clock, and might need some kind of "sudo".  How
do I do that from within "Thonny" (in the "shell" window) ?

Regards,
Rudy Wieser

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.