As @mrlexington says theThe created date is stored in the node_field_data
table as a UNIX timestamp in a cloumn called created
.
Here's the code you would use to fetch the nodes that has been created X days ago, using a direct select query.
$day = 86400; // One day in seconds.
$days = 3; // The amount of days ago to fetch from.
$nids = \Drupal::database()->select('node_field_data', 'n')
->addField('n', 'nid')
->condition('n.created', \Drupal::time()->getCurrentTime() - $days * $day, '>')
->execute()
->fetchField();
$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($nids);
Make sure to inject the database
and the entity_type.manager
services (if possible) when implementing the code yourself.