Jul-06-2020, 07:38 PM
Hi,
Why isn't the date printed correctly?
Why isn't the date printed correctly?
from datetime import datetime as dt now = dt.now() print(hex(now.second)) #return 0x0 print(hex(now.minute)) #return 0x16 print(hex(now.hour)) #return 0x15 print(hex(now.weekday())) #return 0x0 print(hex(now.day)) #return 0x6 print(hex(now.month)) #return 0x7 print(hex(now.year-2000)) #returns 0x14 # actual datetime = 2020 7 6 21 22 0 0(weekday) # sec min hour weekday day month year(2 digit) t = [0x0, 0x16, 0x15, 0x0, 0x6, 0x7, 0x14] w = ["Sun", "Mon", "Tues", "Wed", "Thur", "Fri", "Sat"] print("20%x/%02x/%02x %02x:%02x:%02x %s" %(t[6],t[5],t[4],t[2],t[1],t[0],w[t[3]+1])) #converting to int no change print("20%x/%02x/%02x %02x:%02x:%02x %s" %(int(t[6]),int(t[5]),int(t[4]),int(t[2]),int(t[1]),int(t[0]),w[int(t[3])+1]))