Source Code:
(back to article)
import datetime import pytz # Define a time zone eastern = pytz.timezone("US/Eastern") # Get the current date and time in the Eastern time zone now_eastern = datetime.datetime.now(eastern) # Convert the date and time to the UTC time zone now_utc = now_eastern.astimezone(pytz.utc) print(now_eastern) print(now_utc)
Result:
Report an issue