How do I process this format of timestamp?

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

>Solution :

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'
>>> 

Leave a Reply