-
after running ntp, the time.localtime() is fine, but time.time() is off by some 30 years! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
time.time() returns the seconds since the EPOCH, which is the 1.1.2000 on an ESP32. That's returned by time.gmtime()[0]. Testing it on an ESP32, it returns something like 764_005_006, which is a reasonable number right. For getting a time since 1.1.1970, you have to add 946_684_800. |
Beta Was this translation helpful? Give feedback.
-
The majority of MCU ports of Micropython uses a different epoch (start datetime) than CPython.
See https://docs.micropython.org/en/latest/library/time.html |
Beta Was this translation helpful? Give feedback.
-
RTFM, but then again it’s our 600 paged :-)
IMHO, this should be in CPYthon Micropython difference section.
thanks,
danny
… On 17 Mar 2024, at 17:47, Jos Verlinde ***@***.***> wrote:
The majority of MCO ports of Micropython uses a different epoch (start datetime) than CPython.
epoch of 2000-01-01 00:00:00 UTC. Epoch year may be determined with gmtime(0)[0].
See https://docs.micropython.org/en/latest/library/time.html <https://docs.micropython.org/en/latest/library/time.html>
—
Reply to this email directly, view it on GitHub <#14114 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AETR46MWTEOENDZUDINWH4TYYW3JPAVCNFSM6AAAAABE2JMPIOVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DQMJZGI4DG>.
You are receiving this because you authored the thread.
|
Beta Was this translation helpful? Give feedback.
The majority of MCU ports of Micropython uses a different epoch (start datetime) than CPython.
See https://docs.micropython.org/en/latest/library/time.html