Wednesday, August 27, 2008

Python: Datetime Math

#start code
import datetime
from datetime import datetime as dt
oneDay = datetime.timedelta(days=1)
tomorrow = dt.today()+oneDay
kmlTimeFormat = tomorrow.strftime("%Y-%m-%dT%H:%M:%SZ")
#end code

timedelta resides in the datetime module
today() resides in the datetime.datetime module

then add timedelta (can use months, hours, days, ...) to your datetime.datetime object

I added the kml date string format because thats what i am working on at the moment.


more info