I have imported a number of nodes to a fresh installed Drupal 9. Later, the original content creation date (from the previous website) became important.

I have the information according to the new node ids. I don't know where to update?

I have tried to update the created and changed columns in node_field_data table, but in the content list I still see the import date... Where should i look? (of course I'm open to suggestions with modules, tricks in administration interface etc, I thought updating sql tables would be easier).

1 Answer 1


First off, I would avoid as much as possible making direct DB updates for entities. Drupal 8+'s entity model is tightly bound to its abstraction layers, implemented as hooks. It is considered best practice to always modify entities via the entity API. This will allow Drupal to keep all things in sync.

Now, the short answer to your question is that clearing your site's cache will likely result in the new values being displayed.

A better answer would be to script some PHP in order to iterate through all nodes and update their content creation date via entity API. I often use Drush in order to perform these types of operations. Below is an example that should suit your needs, based on the following presumption:

  • You have loaded your node:date values into an array called $new_node_dates, where the keys are NIDs and the values are Unix timestamps representing the new creation dates. See here for an example of reading a CSV file into an array. If the dates are not in a Unix timestamp format, you can use strtotime() to convert them.

The Drush statement would then be:

drush eval '$node_storage = \Drupal::entityTypeManager()->getStorage("node"); foreach($new_node_dates as $nid => $creation_date) { $node = $node_storage->load($nid); $node->created = $creation_date; $node->save(); }'

Best of luck!

  • Thank you for your nicely detailed and explained answer. Worked like a charm, and also I have a new approach...
    – loker
    Commented May 30, 2022 at 8:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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