0

I have a string which contains seconds and milliseconds since epoc like so:

my_time = '1664958972.070'

I split it like so:

secs, millisecs = my_time.split(".")

I need to convert it to a time format like so: "2022-09-22 17:00:00.001"

I can use the following to convert the seconds:

import time

print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1664958972))
2022-10-05 08:36:12

How can I include the milliseonds into this?

Harry Boy
  • 4,159
  • 17
  • 71
  • 122

0 Answers0