Copy paste friendly:
from datetime import datetime
def extract_unix_timestamp(post_id):
# BigInt needed as we need to treat post_id as 64 bit decimal.
# Python uses arbitrary-precision integers, so no need for explicit BigInt.
as_binary = bin(int(post_id))[2:]
first_41_chars = as_binary[:41]
timestamp = int(first_41_chars, 2) / 1000
# Convert Unix timestamp to a readable format
readable_timestamp = datetime.utcfromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S')
return timestamp, readable_timestamp
# Example usage:
post_id = 7089460991175901184
timestamp, readable_timestamp = extract_unix_timestamp(post_id)
print(f"Unix Timestamp: {timestamp}")
print(f"Readable Timestamp: {readable_timestamp}")