eZ Community » Forums » eZ Publish 5 Platform » Change content published date

Change content published date

Change content published date

Friday 07 June 2013 10:13:44 am - 5 replies


How can I change the pubished date of a content created with a console command? I'm trying to import old articles and keep the published date.

Or maybe can I set it when create content with publishVersion()?

Thanks in advance,


Friday 07 June 2013 6:36:47 pm

It's easy, you only have to set the attribute of the content object of a node - here is a code snippet I used to do this:


 $output = eZContentObjectTreeNode::subTreeByNodeID( $params, array(5299,5300) );

if ($output) {
        foreach($output as $Node) {
                echo $dataMap['publication_date']->DataInt."\n";
                echo $object->attribute( "published" )."PUBLISHED\n";
                if( $dataMap['publication_date']->DataInt != $object->attribute( "published" ) ) {
                        echo "object not equal\n";
                        $object->setAttribute( 'published', $dataMap['publication_date']->DataInt );

All you really need is this:

$object->setAttribute( 'published', <timestamp> );

Edit: clarity

Modified on Saturday 08 June 2013 11:50:26 am by Steven E Bailey

Saturday 08 June 2013 1:42:48 pm

Sorry, I but I forget to say that i'm using ez5, the example code from https://confluence.ez.no/display/EZP51/3.+Managing+Content



Monday 10 June 2013 11:19:00 am

I'm not sure it is possible. You have to create a new isntance of contentCreatestruct (https://github.com/ezsystems/ezpublish-kernel/blob/master/eZ/Publish/API/Repository/Values/Content/ContentCreateStruct.php). You can change the modification date, but not the creation date.  

Maybe, you can try to use the meta data: https://github.com/ezsystems/ezpu...tent/ContentMetadataUpdateStruct.php

Monday 10 June 2013 3:18:29 pm

If it turns out not to be possible, log a feature request in Jira. Setting creation date is an important usecase for rest/data import/content staging

Monday 10 June 2013 5:50:30 pm

I found the way!

$metadataUpdateStruct = $contentService->newContentMetadataUpdateStruct();
$metadataUpdateStruct->publishedDate = new \DateTime('2010-10-10');
$contentService->updateContentMetadata($content->contentInfo, $metadataUpdateStruct);

Thanks everybody for the info,


Modified on Monday 10 June 2013 5:51:30 pm by David Suela


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from