Subtract 2 weeks from a complete date in pyhton

3

I'm thinking of a date in this format:

time.strftime("%d/%m/%Y") // 00/00/0000

I want to subtract two weeks from that date, but I do not know how to do it.

    
asked by anonymous 20.01.2017 / 18:48

1 answer

5

You can use timedelta and pass as parameter to amount of days you want to replace from a date.

from datetime import datetime, timedelta

hoje = datetime.today() - timedelta(days=14)
    
20.01.2017 / 19:11