How many days are left from today to this date

I have a date - 2015.05.20

What is the best way to calculate with python how many days are left from today to this date?

from datetime import * today = date.today() future = date(2015,05,20) ??? 
+6
source share
2 answers
 import datetime today = datetime.date.today() future = datetime.date(2019,9,20) diff = future - today print (diff.days) 

diff is a timedelta object.

+18
source

subtract them.

 >>> from datetime import * >>> today = date.today() >>> future = date(2015,05,20) >>> str(future - today) '1326 days, 0:00:00' >>> (future - today).days 1326 
+3
source

All Articles