How can I process an output like
"TimeStamp: 1635251181000"
into a readable format in Python. I tried datetime.fromtimestamp()
but I got an error like
OSError: [Errno 22] Invalid argument
That's a Unix time_t
value (seconds since 1/1/1970), multiplied by 1000 to include milliseconds. It's the same value returned by time.time()*1000
. So:
>>> t = 1635251181000
>>> time.ctime(t/1000)
'Tue Oct 26 05:26:21 2021'
>>>