python - the number of days to the date of conversion

If today was 0 #

def getdate(day):
    today = datetime.datetime.now()
    deviation = datetime.timedelta(days=-day)
    return (today + deviation).strftime('%Y-%m-%d %H:%S:%M')

print(getdate(0))

 

Guess you like

Origin www.cnblogs.com/chaoqi/p/11704929.html