Date strftime('%d%m%y') date to be of yesterday

Tim Golden mail at timgolden.me.uk
Thu Oct 22 12:14:46 CEST 2009


baboucarr sanneh wrote:
> 
> Hi all
> 
> I want to output the date of the with this format strftime('%d%m%y') but the date ie '%d' should be the date of yesterday
> eg
> 
> import time
> strftime('%d%m%y') # something like minus a day..
> Thank you..am a newbie to python


<code>
import datetime
yesterday = datetime.date.today () - datetime.timedelta (days=1)
print yesterday.strftime ("%d%m%y")
</code>

TJG



More information about the Python-list mailing list