MicroPython - Converting to / from timestamp. #14243
Replies: 2 comments 3 replies
-
try: time.localtime(timestamp) https://docs.micropython.org/en/latest/library/time.html >>> time.localtime(0)
(2000, 1, 1, 0, 0, 0, 5, 1) to convert back use: >>> time.mktime((2000, 1, 1, 0, 0, 0, 5, 1))
0 |
Beta Was this translation helpful? Give feedback.
-
You don't say what you mean by a "timestamp". But if you mean an ASCII string representing a date/time, you can use the Parsing one of those is more involved, especially if you have to deal with arbitrary formats. Here's a function I wrote to make ISO8601 timestamps:
|
Beta Was this translation helpful? Give feedback.
-
Hi,
Can anyone please advise me as to how to make a timestamp and conversely convert from a timestamp using MicroPython?
Thanks and kind regards,
jB
Beta Was this translation helpful? Give feedback.
All reactions