How to remove 0:00:00
from the output of datetime.date()
function? For example:
import datetime
now = datetime.datetime.now()
year1 = now.strftime("%Y")
month2 = now.strftime("%m")
day3 = now.strftime("%d")
year = int(year1)
month = int(month2)
day = int(day3)
first_day = datetime.date(2021,8,1)
second_day = datetime.date(year,month,day)
daysleft = first_day - second_day
print(daysleft)
I get the output:
9 days, 0:00:00
If you didn't understand the question title, My main goal is to remove the 0:00:00
before the period (.). I've seen many other questions like this (in stack overflow/exchange and other websites), but it was nothing in python coding language.