How to set the creation date

by Jens W. Klein last modified Dec 30, 2008 03:02 PM

This page describes how to set the creation date and effective date to a given value.

Im ZMI add a Script (Python) to your Plone's root, name it setdate and fill it with the following code:

 # set creationDate and effectiveDate to a given date.
 # by jensens

 date="-".join(traverse_subpath)

 try:
     d= DateTime(date)
 except:
     return "problem with subpath '%s'. usage: setdate/YYYY/MM/DD" % date

 context.setModificationDate(date)
 context.setCreationDate(date)
 context.setEffectiveDate(date)
 context.reindexObject()

 return "date on '%s' successfully set to %s." % (context.title_or_id(), date)

Navigate to the object you want to change and append to its URL setdate/2005/09/17.

Example:

 http://www.linux.org/Members/torvalds/news_linuxstarted/setdate/1991/08/25

It works not for Plone 2.1.1 (for some reason there is setModificationDate and setCreationDate not available in restricted code. This will be fixed in upcoming Archetypes releases (just replace ExtensibleMetadata.py by the one from Archetypes SVN release-1_3-branch). Here both methods are protected by Manage Portal.

Thats it.