2

I'm creating duplicates of nodes by doing

$node->createDuplicate();

It duplicates all the values of all the fields but but it duplicates the created and updated time as well. I want both of those set to now. I know how to set the created time.

$clone->setCreatedTime(time());

However there doesn't seem to be a function or a property for setting the updated time. I read up on the source code of the Node class but couldn't find any mention of it.

Is there any kind of method where you can set the updated time of a node?

3

I think you can change the value by accessing the variable and saving it then

$clone->changed->value = time();
$clone->save();
| improve this answer | |
  • Thanks! That was it. I was mistakenly searching for things with the term 'updated' when I should have been searching for the 'changed' terminology. – Matt Apr 5 '18 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.