Date & Time: ============ ==> To handle the date and time: there are three modules in Python Library: 1) time module 2) calendar module 3) datetime module 1) time module: =============== time(): ===== return the total time in float. ==> consider the time period from Jan-01, 1970 12 am to till Syntax: import time time.time() import time t = time.time() localtime(): =========== which includes: year, month, date, time (hours, minutes, seconds..) Syntax: time.localtime() return the local time in tuple format. import time lt = time.localtime() print(lt) asctime(): ========== ==> use to print the time in a format. Syntax: time.asctime(local-time) import time lt = time.localtime() print("Local time in Tuple Format : ",lt) t = time.asctime(lt) print("The Local Time in time format : ",t) ==================================== 2) calendar Module: =================== month(): ======= required to display the calendar of the specified year and month Syntax: import calendar calendar.month(year, month-number) month-number ==> 1 to 12 import calendar month = calendar.month(2024,11) print(month) print(calendar.month(2000,6)) =============================================== 3) datetime Module: =================== date(): ======= Syntax: datetime.date(year, month, day) month ==> 1-12 day ==> 1-30/1-31/1-28 import datetime d1 = datetime.date(1993, 6, 20) d2 = datetime.date(2050, 11,4) print(d1) print(d2) ============================ now(): ===== Syntax: datetime.datetime.now() import datetime n = datetime.datetime.now() print(n) =========================================== Minimum date and Maximum date: ============================== from datetime import date min_date = date.min max_date = date.max print(min_date) print(max_date) ============================================= Individual Properties to handle date and time: ============================================= import datetime t = datetime.datetime.now() print(t) print("Year = ",t.year) print("Month = ",t.month) print("Day = ",t.day) print("Hours = ",t.hour) print("Minutes = ",t.minute) print("Seconds = ",t.second) ============================================ today(): ======= Syntax: date.today() from datetime import date t = date.today() tf1 = date.fromisoformat('1993-06-20') tf2 = date.fromisoformat('20051119') tf3 = date.fromisoformat('2005-W16-4') print(t) print(tf1) print(tf2) print(tf3) =================================================== Format Specifiers: ================== %a ==> day name in short form %A ==> day name in full form %w ==> week day number 0 to 6 sun = 0 mon = 1 tue = 2 wed = 3 thu = 4 fri = 5 sat = 6 %d ==> month day number 30 days ==> 1 to 30 31-days ==> 1 to 31 28-days ==> 1 to 28 %b ==> month name in short form %B ==> month name in full form %m ==> month number 1 to 12 %y ==> Year in short form %Y ==> Year in full form %H ==> Time in 24 hours format (0 to 23) %I ==> Time in 12 hour format (0 to 11) %p ==> am/pm %M ==> minute %S ==> Seconds %Z import datetime lt = datetime.datetime.now() print(lt.strftime("%a")) print(lt.strftime("%A")) print(lt.strftime("%w")) print(lt.strftime("%d")) print(lt.strftime("%b")) print(lt.strftime("%B")) print(lt.strftime("%m")) print(lt.strftime("%y")) print(lt.strftime("%Y")) print(lt.strftime("%H")) print(lt.strftime("%I")) print(lt.strftime("%p")) print(lt.strftime("%M")) print(lt.strftime("%S")) print(lt.strftime("%Z")) print("The Time in the format:",lt.strftime("%B-%d-%Y %H:%M:%S %p")) print(t)