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

convert javascript Date.now to pandas to_datetime

I am trying to convert timestamp data that has been fetched with javascript Date.now() and get the data and time into pandas.DataFrame.
I am using pandas.to_datetime to convert the timestamp.

However According to the doc The static Date.now() method returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.

so, converting the timestamp 1636460191573 using pd.to_datetime('1636460191573') give Timestamp('1970-01-01 00:27:16.460191573')

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

How do I get the date and time from the timestamp in dd/mm/yyyy and hh:mm:sec format?

>Solution :

Add parameter unit:

print (pd.to_datetime('1636460191573', unit='ms'))
2021-11-09 12:16:31.573000
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