I got into a problem or, if possible, I will add a turn! Not sure interesting! In python datetime library to get time difference, like in the following snippet.
>>> import datetime
>>> datetime.datetime.now() - datetime.datetime.now()
datetime.timedelta(-1, 86399, 999958)
>>> tnow = datetime.datetime.now()
>>> datetime.datetime.now() - tnow
datetime.timedelta(0, 4, 327859)
I would like to understand why it datetime.datetime.now() - datetime.datetime.now()outputs as -1 days, 86399 seconds , while assigning the current time to a variable and a computational difference gives the desired result 0 days, 4 seconds .
The results seem a bit confusing, it would be helpful if someone could decrypt what goes after
Note. I am using Python 2.7
source
share