Turn utime.time() into unix time float

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
roland_vs
Posts: 89
Joined: Tue Dec 08, 2015 8:28 pm
Location: Netherlands
Contact:

Turn utime.time() into unix time float

Post by roland_vs » Sun Aug 05, 2018 11:24 pm

Turn utime.time() into unix time float

I would like to convert mpy utime.time() into the unix time that is a float().

SpotlightKid
Posts: 463
Joined: Wed Apr 08, 2015 5:19 am

Re: Turn utime.time() into unix time float

Post by SpotlightKid » Mon Aug 06, 2018 12:08 am

Code: Select all

>>> import datetime
>>> delta = (datetime.datetime(2000, 1, 1, 0, 0, 0) - datetime.datetime.fromtimestamp(0)).total_seconds()
>>> delta
946681200.0
Just add this delta to the timestamps produced by utime.time().

User avatar
roland_vs
Posts: 89
Joined: Tue Dec 08, 2015 8:28 pm
Location: Netherlands
Contact:

Re: Turn utime.time() into unix time float

Post by roland_vs » Mon Aug 06, 2018 7:29 am

TNX

Post Reply