Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4856

MicroPython • Re: pico onboard rtc and lack of datetime module

$
0
0
Thanks all.
Converting to epoch time in seconds makes sense. Like I say, I don't need to know how to set the rtc to the correct time, I need to now how to compare times and I think doing it with seconds is the way to go. However I am stuck here:

Code:

import timertc=machine.RTC()timestamp=rtc.datetime()print(str(timestamp))tnow = time.mktime(timestamp)print(tnow)gm=time.gmtime(tnow)print(gm)
results in:
>>>
(2021, 1, 1, 4, 0, 36, 31, 0)
1609473636
(2021, 1, 1, 4, 0, 36, 4, 1)
>>>
This doesn't look right. tnow is too short and the last two numbers are the minutes. I have misunderstood somehow.

Statistics: Posted by jimseng — Thu Apr 25, 2024 6:35 am



Viewing all articles
Browse latest Browse all 4856

Trending Articles