How to convert epoch time to real date time?

106 Views Asked by At

I am using a machine vision camera and when the camera gets an image, it returns the timestamp (in nanoseconds). I converted the timestamp to DateTime format.

new_time_ns = 15545164216329
new_time_s = new_time_ns * 1.e-9 # convert to second
datetimeformat = datetime.fromtimestamp(new_time_s).strftime('%Y-%m-%d %H:%M:%S')

However datetimeformat returns 1970-01-01 05:54:41. When I ran the code, the real datetime was 2022-06-01 17:25:00 (ignore the seconds) How can I get the datetimeformat with the actual time when I record the video?

0

There are 0 best solutions below