[Solved] Convert Timestamp(Nanoseconds format) to datetime [closed]


You should be using = to assign values and not :

You can do like this.

import datetime
example_timestamp =  int('1629617204525776950')

timestamp_to_date_time = datetime.datetime.fromtimestamp(example_timestamp/1000000000).strftime('%Y-%m-%d %H:%M:%S,%f')
print(timestamp_to_date_time)
2021-08-22 07:26:44,525777

solved Convert Timestamp(Nanoseconds format) to datetime [closed]