change datetime to utc python code example
Example 1: python datetime to utc
from datetime import timezone
timestamp = dt.replace(tzinfo=timezone.utc).timestamp()
Example 2: python datetime from timestamp utc
dt_object = datetime.fromtimestamp(timestamp)