i basicly need to get actual time(time1) and see how many hours and minutos to time2. Its a countdown, how many time untill time2.
I have been making this
def schedule_task():
exp_h = 23
exp_m = 5
now = datetime.datetime.now()
if len(str(exp_m))==1:
exp_m=str("0")+str(exp_m)
date_time_str = str(exp_h)+":"+str(exp_m)+":00"
exp_now = datetime.datetime.strptime(date_time_str,"%H:%M:%S").time()
fdate = datetime.datetime.now().strftime("%H:%M:%S")
locl_h = now.strftime("%H")
locl_m = now.strftime("%M")
remain = datetime.datetime.combine(now.today(), fdate.time()) - datetime.datetime.combine(now.today(), exp_now)
lbl_remaing.config(text="Request will be sent in "+str(remain), bg="darkgrey",fg="blue")
if locl_h.strip()==exp_h.strip() and locl_m.strip()==exp_m.strip():
print("run func")
else:
lbl_remaing.after(1000, schedule_task)
Having this error
print("----> ",datetime.datetime.combine(now.today(), fdate.time())
- datetime.datetime.combine(now.today(), exp_now.time())) AttributeError: 'str' object has no attribute 'time'