faqts : Computers : Internet : Web Servers : Zope : Common Problems : Date / Time

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

5 of 9 people (56%) answered Yes
Recently 4 of 8 people (50%) answered Yes

Entry

Is there an easy way to increment the month or year of the DateTime object?

Jul 29th, 2000 22:12
unknown unknown, Jim Sanford


Problem:
Adding a numeric value increments the day. Incrementing the year is 
easily doable, but incrementing the month is significantly more 
difficult. So I'm just curious if there's a function that will actualy 
modify the parts of a DateTime object, or something way that I'm not 
thinking of to easily increment the month.
Solution:
<dtml-var
"_.DateTime(_.str(ZopeTime().month()+1)+'/'+_.str(ZopeTime()
.day())+'/'+_.str(ZopeTime().year()))">
will give you a datetime object one month in the future