Convert datetime to Different Time Zone in Python (3 Examples) | Change Date & Time to CET, CST, EST

Описание к видео Convert datetime to Different Time Zone in Python (3 Examples) | Change Date & Time to CET, CST, EST

How to convert the time zone of a datetime object to another time zone such as CET,CST,EAT, EST, and UTC in the Python programming language. More details: https://statisticsglobe.com/convert-d...
This tutorial was created in collaboration with Gottumukkala Sravan Kumar: https://statisticsglobe.com/gottumukk...
Python code of this video:

from datetime import datetime
import pytz

my_datetime = datetime(2023, 2, 13, 17, 10, 27, tzinfo = pytz.utc)
print(my_datetime)

my_datetime_utc = my_datetime.strftime('%Y-%m-%d %H:%M:%S %Z%z')
print(my_datetime_utc)

my_datetime_cet = my_datetime.astimezone(pytz.timezone('Europe/Berlin')).strftime('%Y-%m-%d %H:%M:%S %Z%z')
print(my_datetime_cet)

my_datetime_cst = my_datetime.astimezone(pytz.timezone('US/Central')).strftime('%Y-%m-%d %H:%M:%S %Z%z')
print(my_datetime_cst)

my_datetime_est = my_datetime.astimezone(pytz.timezone('US/Eastern')).strftime('%Y-%m-%d %H:%M:%S %Z%z')
print(my_datetime_est)

Follow me on Social Media:
Facebook – Statistics Globe Page:   / statisticsglobecom  
Facebook – R Programming Group for Discussions & Questions:   / statisticsglobe  
Facebook – Python Programming Group for Discussions & Questions:   / statisticsglobepython  
LinkedIn – Statistics Globe Page:   / statisticsglobe  
LinkedIn – R Programming Group for Discussions & Questions:   / 12555223  
LinkedIn – Python Programming Group for Discussions & Questions:   / 12673534  
Twitter:   / joachimschork  

Music by bensound.com

Комментарии

Информация по комментариям в разработке