I am migrating content from Drupal 7 to Drupal 8. Migration works fine except the changed date for node get changed to the current time. I want to set the timestamp to the Drupal 7 timestamp. I have tried out the following but it is not working.

        $changed_date = $node->getChangedTime();
        $node->set($source['parent_field_name'], $paragraph_target);
        $node->changed->value = $changed_date;
        // print_r($changed_date);die;

Not personally tested, but according this issue is a problem for already existing entities, while it should be resolved for new ones. Also, there's a module that seems to address this issue. So, I'd say:

  1. try to create the node only in one step, to see if that preserve the original timestamp
  2. if that fails, try either the patch or the module
  • Thanks.... the module on;y works for non-translated content... When I add it for translated content the module doesn't work.
    – Subhash
    Feb 3 at 16:43

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.