So I am trying to create a 'planner' or diary. I am trying to create the code so it advises you how much time you have left in the day before you go to bed or before you have to do an activity you have planned.
late = timedelta(hours=23)
current_time = now.hour,now.minute
time_left = (late - current_time).minutes
print 'So if the time is %s:%s, That means you have %s minutes left' % (now.hour,now.minute,time_left)
From looking at other threads this was my approach but I have tried several other methods like
late = datetime(datetime.day,datetime.month,datetime.year,23,00)
Again saw this on other threads. I have tried so many methods now I have begun to confuse myself with how to solve it.
Thanks again for any help in advance
EDIT: when using
late = datetime(datetime.day,datetime,month,datetime.year,23,00)
I got the Valuerror 'day is out of range month'
and with the current code
late = timedelta(23,00)
I got a typeerror 'unsupported operand type(s) for -: 'datetime.timedelta' and 'tuple' In this example.
I just want the code to output the time difference between 11:00pm (or 23:00) and the current time in minutes. Sorry for not being clearer
ANSWERED EDIT: Thank you to the comments and the answer the problem I was making the code to complicated and not using datetime() correctly,
y = today.year
m = today.month
d = today.day
late = datetime(y,m,d,23,0,0)
I had the year month and day the wrong way round and had the format for the time wrong.
Thanks for the help guys.