# Chapter7 Folder # myDateTime.py # Page 303 Chapter 11 print("--- Date Time Examples ---") # DateTime Python Standard Module import datetime # import MODULENAME # MODULE NAME datetime # CLASS NAME datetime currentDateTime = datetime.datetime.now() # Y M D H M S M UTC print(currentDateTime) # 2024-05-09 12:26:06.635445 print( type(currentDateTime) ) # b_month = input("Birthday Month: ") b_day = input("Birthday Day: ") b_year = input("Birthday Year ex.YYYY: ") birthday_string = b_year + "-" + b_month + "-" + b_day print(birthday_string) # 2 primary string methods for datetime # strftime() -> format a date time # strptime() -> converts a string class type to a datetime class type converted_birthday = datetime.datetime.strptime(birthday_string, "%Y-%m-%d") # page 307 print("--- Birthday String Class Type---") print( type(birthday_string) ) # string print("--- Converted Birthday Class Type ---") print( type(converted_birthday) ) # datetime.datetime # strftime() format time page 309 # Thursday December 9, 2024 # 12/05/2024 # Thu Dec 05 5 06 6 05 06 24 print(currentDateTime) # 2024-05-09 13:55:13.142655 formatted_date = currentDateTime.strftime("%A %B %d, %Y") print(formatted_date) # Thursday May 09, 2024