from datetime import date, datetime, timedelta def dow(yy,mm,dd): dt = date(yy,mm,dd) return int(dt.strftime('%w')) print('dow: ', dow(2023,12,3)) #------------------------------------------------- now = date.today() print("Today is ", now) # print(now.year, now.month, now.day) due = now + timedelta(days=14) print("today + 14 days: ", due) day1 = date(now.year, 9, 1) print((day1-now).days, " days") #------------------------------------------------- d1 = now.strftime("%d/%m/%Y") # dd/mm/YY print("d1 =", d1) # Textual month, day and year d2 = now.strftime("%B %d, %Y") print("d2 =", d2) d3 = now.strftime("%m/%d/%y") # mm/dd/y print("d3 =", d3) # Month abbreviation, day and year d4 = now.strftime("%b-%d-%Y") print("d4 =", d4) #------------------------------------------------- # datetime object containing current date and time now = datetime.now() #print("now =", now) print(now.year, now.month, now.day, str(now.hour)+":"+str(now.minute)+":"+str(now.second)) dt_string = now.strftime("%d/%m/%Y %H:%M:%S") # dd/mm/YY H:M:S print("date and time =", dt_string) print('-----')