Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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'
>>> 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading