Date & Time Module: =================== ==> To handle the date and time in Python: there are three modules: 1) DateTime Module 2) Time Module 3) Calendar Module ==> Built-in modules in Python library. we should import these before going to define. Syntax: import module-name Ex: import numpy time(): ====== ==> built-in function defined in "time" module. ==> return: the total time in float derived from jan-1, 1970, 12 am to till Syntax: import time time.time() import time period = time.time() # return the time in float # since jan1, 1970 12 am to till print(period) localtime(): ============ ==> built-in function in time module ==> can return: full time includes: year, month, date, time: hours, minutes, seconds etc. Syntax: time.localtime() import time t = time.localtime() print(t) ======================================== Time in specified Format: ========================= asctime(): ========== Syntax: time.asctime(time value) # WAP TO PRINT THE CURRENT TIME. import time current_time = time.localtime() ct = time.asctime(current_time) print(current_time) print(ct) ================================================= Calendar Module: ================ month(): ======== Syntax: calendar.month(year, number_month) import calendar c = calendar.month(1989,6) print(c) ==================================== Datetime: ========= now(): ===== import datetime t = datetime.datetime.now() print(t) ================================== Format Specifiers: ================== %a ==> weekday name in short version %A ==> weekday name in full version %w ==> day number Sun = 0 mon = 1 Tue = 2 Wed = 3 Thu = 4 Fri = 5 Sat = 6 %d ==> day number in the month November ==> 30 days ==> 1 to 30 %b ==> Month Name in short form %B ==> Month name in full form %m ==> month number 12-months ==> 1 to 12 %y ==> year in short form ex: 2024 short ==> 24 2000 short ==> 00 %Y ==> year in full form %H ==> Hours ==> 0 to 23 ==> Time in 24 hour fomat %I ==> Time in 12-format %p ==> time with AM/PM %M ==> Only minutes %S ==> Only Seconds import datetime t = datetime.datetime.now() print(t.year) print(t.month) print(t.day) print(t.hour) print(t.minute) print(t.second) print(t.strftime("%a")) print(t.strftime("%A")) print(t.strftime("%w")) print(t.strftime('%d')) print(t.strftime('%b')) print(t.strftime("%B")) print(t.strftime('%m')) print(t.strftime('%y')) print(t.strftime('%Y')) print(t.strftime('%H')) print(t.strftime('%I')) print(t.strftime('%p')) print(t.strftime('%M')) print(t.strftime('%S')) print("The Current Time = ") print(t.strftime("%d-%b-%Y %H:%M:%S %p"))