Spike7 Spike7 - 7 months ago 52
Python Question

How to convert nanoseconds of uptime into a readable date time format

I have extracted accerometer data from a android wearable. While looking at the data i realised the timestamp is not unix covertable. After research i saw the timestamp was actually nanoseconds in uptime. My question is the same as Accelerometer SensorEvent timestamp. However due to me not knowing Java i dont know how convert it using the solutions provided. Is there any python ways i can convert the nanoseconds in uptime into a readable date time format? An example of the timestamp would be "45900482044637".


To get the uptime in human-readable format in Python:

>>> from datetime import timedelta
>>> ns = 45900482044637
>>> print(timedelta(microseconds=round(ns, -3) // 1000))