13 digit timestamp python 1

13 digit timestamp python

import datetime

timestamp = "1523126888080"
your_dt = datetime.datetime.fromtimestamp(int(timestamp)/1000)  # using the local timezone
print(your_dt.strftime("%Y-%m-%d %H:%M:%S"))  # 2018-04-07 20:48:08, YMMV

Here is what the above code is Doing:
1. Convert the timestamp to seconds.
2. Convert the seconds to a datetime object.
3. Format the datetime object to a string.

Similar Posts