Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1579

Python • subtracting times with datetime

$
0
0
Hi
I have been trying to find an answer and I just can't solve what should be an easy thing so it is time to ask.
I have a mysql time in hours, minutes seconds. I simply want to subtract the time now from the mysql time to discover how many minutes are left but I have failed after hours.
The problem is time now includes the date as well as the hours. Or it includes the timedelta.
Example:

Code:

def timediff(endtime):#endtime is in the format hours, minutes seconds as a mysql time fieldnow = datetime.datetime.now().time()print(now-endtime)
This should be really easy. Can someone help?

Statistics: Posted by jimseng — Tue Nov 11, 2025 10:44 am



Viewing all articles
Browse latest Browse all 1579

Trending Articles