python convert twitter id to date 1

python convert twitter id to date

from datetime import datetime
shifted = id >> 22 
timestamp = shifted + 1288834974657
time_created = datetime.fromtimestamp(timestamp/1000).strftime('%Y-%m-%d')

Here is what the above code is Doing:
1. Shifting the bits to the right by 22 places.
2. Adding the timestamp to the shifted bits.
3. Converting the timestamp to a readable format.

Similar Posts