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: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.
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)
>>>
(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